How to Sort Lines Alphabetically
To sort lines alphabetically, paste them into the box. The tool puts the lines in A to Z order and shows the result on the right. This is the Example list with the default settings:
Apple
apple
banana
fig
item1
item2
item10
pearApple and apple are treated as equal when sorting, so they stay in the order they had in your list. Numbers inside a line are read as numbers, which is why item2 comes before item10. Switch to Z to A to reverse the alphabetical order.
Natural Order: item2 Before item10
A plain alphabetical sort compares character by character, so item10 comes before item2, because 1 is smaller than 2. That is rarely what you want for file names, versions and numbered lists. Natural order is on by default and compares the digits as whole numbers. Turn it off to get the strict character order:
Natural order on: item1, item2, item10
Natural order off: item1, item10, item2Capital Letters, Accents and Leading Spaces
- Match case off: Apple, apple and APPLE count as equal. Equal lines keep the order they had before.
- Match case on: capitals count, and for the same letter the lowercase line is put first, so apple comes before Apple.
- Accents: letters such as é sort next to e, not after z. The exact order of accented and non-Latin letters follows your browser's rules for text, so it can differ between languages and browsers.
- Ignore leading spaces: compares the lines as if the spaces at the start were not there. The lines are not changed, so an indented line stays indented.
Sort by Number, by Length, Reverse or Shuffle
Sort by number looks at the first number in each line and orders the lines by its value, so 9 comes before 12 and 100. Negative numbers and decimals with a point work. Commas inside numbers do not. A line without any number is placed after the numbered lines, in its original order. With this list:
Invoice 12 paid
Invoice 9 open
Invoice 100 open
Notes
→ Invoice 9 open
Invoice 12 paid
Invoice 100 open
Notes- By length: orders lines by the number of characters, short first or long first. Lines of the same length keep their order.
- Reverse the order: turns the list upside down without sorting it.
- Random order: shuffles the list. The order is different every time you change the list or an option, because it is random by design. To pick a few random lines or repeat an order with a seed, use Shuffle Lines.
Remove Empty Lines and Duplicates While You Sort
Remove empty lines is on by default, because blank lines would be collected at the top of an A to Z list. Turn it off to keep them. Remove duplicates keeps the first copy of each line before the sort, and it follows the Match case setting. With Example and Remove duplicates on, apple is dropped because Apple came first.
For more control over duplicates, Remove Duplicate Lines can also trim spaces and show only the repeated lines. A sorted list can be turned into one line with Column to Comma Separated List.
Sorting Lines in Other Programs
Many text editors have a sort lines command, and word processors can sort paragraphs. Where yours does not, paste the lines here, sort them and paste the result back. On the command line, sort file.txt sorts a file alphabetically, sort -n file.txt sorts by number and sort -u file.txt sorts and removes duplicates.
To change the capital letters of a spreadsheet column first, the Excel Case Converter works on whole files. To see how often each word of a text occurs, use the Word Frequency Counter.
Limits and Privacy
- The tool sorts whole lines. It cannot sort by a column or a field inside a line.
- Sort by number uses only the first number in each line.
- Input is limited to 2,000,000 characters.
Your list is sorted by code running in your browser. It is not sent to a server and not stored. See the Privacy Policy for details.