Sort text lines

Sort lines A to Z by your page language's rules, with natural number order, case and accents ignored, and blank lines dropped. Ascending only.

Output
Enter text to see output.

What to know

The sorter drops blank lines, then orders the rest ascending using the collation rules of the page language. Capitals and accents are ignored when comparing, and digits inside a line are compared by value, so file2 comes before file9 and file9 before file10 instead of the usual file10, file2, file9.

Because case and accents are ignored, items that differ only in those are treated as equal and keep the order in which you entered them. From résumé, resume and Resume as input, the three come out in that same sequence rather than being rearranged.

The language matters. On the English page, apple, Apple and banana sort alphabetically; on the Spanish page, ñ sorts after n, so nube, nuez, ñu, oso; on the Japanese page, hiragana and katakana of the same sound sort side by side; and on the Korean page, Hangul syllables sort ahead of Latin letters.

Lines are not trimmed first, so a line that begins with spaces sorts before the others. If that is unintended, run trim whitespace first. There is no descending option, so to reverse the order, sort here and reverse the list in your editor or spreadsheet.

Choose a specific task 10
Related tools 4
How to use Sort text lines
  1. Paste an unsorted list such as file10, File2, file9, apple, Banana into the Text input box.
  2. Check that the Output panel reads apple, Banana, File2, file9, file10, with numbers in natural order.
  3. If a few lines are indented, run trim whitespace first so they sort with the rest.
  4. Copy the sorted list, or save it with the download icon as chatcument-text-output.txt.

Quick answers

Why does file10 come after file9?

Digits inside a line are compared as numbers, so the sorter follows natural order. Plain text sorters put file10 before file2 because they compare character by character.

Is the order different on the Spanish or Korean page?

Yes. The page language supplies the collation rules, so ñ follows n in Spanish and Hangul syllables come before Latin letters in Korean.

Are blank lines kept?

No, blank and whitespace-only lines are discarded before sorting, so the output has no gaps.

Can I sort in reverse?

There is no descending option. Sort here, then reverse the lines in your editor or give the spreadsheet column a Z to A sort.