Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to the Power Users community on Codidact!

Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.

In Word, how do I readily sort a string of numbers separated by commas?

+3
−2

My string of numbers is 32, 29, 10, 30, 40, 39, 48, 12, 42, 41, 38, 18. How can I sort this from smallest to largest most readily?

I clicked OK as pictured below, but nothing happened. Then I picked Headings, whilst keeping all the other settings, but again nothing happened. Then I picked Field 1, while keeping all the other settings, but again nothing happened. Why?

I am not asking about unproductive methods like brute force. 'Sort Text' worked when I hit "Enter", and started each number on a new line. But this gruntwork is impractical, if the string contains many numbers.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

Post Feedback (1 comment)

2 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+1
−0

You can't do that in Word.

Word's Sort command operates on "fields" in separate rows. It is nominally for Tables, but if the selected data is not in an actual Table then it treats each row of text as if it were a row of a Table. Note that each row here is a full Paragraph, defined by a hard return, not a line as defined by text flowing between margins.

There is an option for separating fields by commas, but that is for selecting which field within each row is sorted. For example, if your text is:

a,1,2
b,10,20
c,5,10
d,7,25

then if you sort by Paragraph or by Field 1 then it will sort as shown. If you select Field 2 then it will sort to:

a,1,2
c,5,10
d,7,25
b,10,20

and if you select Field 3 then it will sort to:

a,1,2
c,5,10
b,10,20
d,7,25

It just doesn't seem to have any way to sort within a row. This is consistent with the general and historical usage of CSV/comma-delimited data as database data - each row is a record and sorting is typically via a numbered field within the rows.

If you have a large pre-existing data set consisting of a single long row of comma-delimited data, you can search/replace to change , to Paragraph Mark (select from Special or enter ^p) and then Sort the results.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

+2
−0

The Sort Text function shown in the snapshot is intended to sort lists. In Microsoft Word, a list has each element member in a new line (paragraph). Considering this:

  1. Convert the numbers separated by commas into a list. This could be done by using search and replace, replacing the commas and spaces with a paragraph mark. Use ^p in the replace text box for a paragraph in the search and replace dialog.
  2. Select the list
  3. Open Sort text
  4. Verify that the options are Paragraphs, Number and Ascending, then click OK.
  5. If needed, replace the paragraph marks with commas and spaces. Use ^p in the find text box for a paragraph in the search and replace dialog.

NOTES:

While the default view is the Print Layout view, working on it might make it difficult to identify when a line is caused by a paragraph, a line break, page margins or other objects.

I'm not including screenshots as I'm using Word for Mac. The dialogs are different but the Sort Text feature work the same way. On the other hand, the official help article already includes snapshots, and it's available for three platforms Windows, Mac and Web : Sort a list alphabetically in Word.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »