How to sort lines
- Paste or type your text, one item per line.
- Pick a sort method and a direction.
- Copy the sorted result or download it as a text file.
The output updates as you change any option, so you can try methods side by side.
Sort methods
- Alphabetical: orders lines by letters, following the rules of your language, so accented letters sort sensibly.
- Natural: treats numbers inside text as numbers, so file2 comes before file10.
- Numeric: sorts by the first number found in each line.
- Line length: sorts from shortest to longest, or the reverse.
Clean up while you sort
Tick Trim lines to remove spaces at the start and end, Remove empty lines to drop blanks, and Remove duplicates to keep only the first copy of each line. The stats show how many lines went in, came out, and were removed.
Good to know
The sort is stable, so lines that compare as equal keep their original order. Case is ignored by default, so apple and Apple sit together. Tick Case sensitive to treat them as different, with the capital form listed first, so A comes before a.
Looking for a specific kind of sort? Try alphabetical, reverse, numerical or by length. The sorting guide covers the command line, Excel and code. To count what you have, use the line counter.