Sort pasted lines alphabetically in ascending or descending order, with natural number ordering.
Example
“item 10, item 2, Item 1, item 1” sorts to Item 1, item 1, item 2, item 10, and the file names file-2.txt, file-10.txt and file-1.txt sort to file-1.txt, file-2.txt, file-10.txt.
Calculation method
Whole lines are compared with your browser’s locale-aware collator, and numeric sorting is enabled so numbers inside text are ordered by value rather than character by character. Ascending runs A to Z and descending runs Z to A.
Important notes
Leading spaces are part of a line and push it ahead of the others, so remove them with the Whitespace Remover first. Duplicate lines are kept as they are; run the Duplicate Line Remover before or after sorting if each line should appear only once.
Natural number order
Lines are compared as whole lines with natural numeric sorting, so numbers inside text are ordered by value rather than character by character. “item 10, item 2, Item 1, item 1” sorts to Item 1, item 1, item 2, item 10, and file names file-2.txt, file-10.txt and file-1.txt sort to file-1.txt, file-2.txt, file-10.txt. A simple character sort would put 10 before 2 because the digit 1 comes first, which is rarely what people expect in lists of versions, chapters or invoice numbers.
Ascending, descending and capital letters
Choose ascending for A to Z or descending for Z to A: Banana, apple and Orange in descending order become Orange, Banana, apple. By default capital and small letters are treated as equal, so lines that differ only in case keep their original relative order, as Item 1 and item 1 do above. Turn on case-sensitive sorting to separate them; then b, B, a and A sort to a, A, b, B, with the lowercase form of each letter first.
Language order and preparation
Sorting uses your browser’s language rules, so accented letters are placed near their base letters and alphabets other than Latin follow their own collation order; Japanese kana and kanji may not appear in dictionary reading order. Leading spaces are part of a line and move it ahead of other lines, so remove them with the Whitespace Remover first. Duplicates are kept; use the Duplicate Line Remover before or after sorting if each line should appear only once.
Worked examples| Input | Result |
|---|
item 10↵item 2↵Item 1↵item 1 · A→Z | Item 1↵item 1↵item 2↵item 10 |
file-2.txt↵file-10.txt↵file-1.txt · A→Z | file-1.txt↵file-2.txt↵file-10.txt |
Banana↵apple↵Orange · Z→A | Orange↵Banana↵apple |
b↵B↵a↵A · A→Z · case-sensitive | a↵A↵b↵B |
Frequently asked questions
Why does item 2 come before item 10?
Because numbers inside the text are compared by value. A plain character sort would put 10 first, since the digit 1 comes before 2, which is rarely what you want for versions, chapters or invoice numbers. Natural ordering fixes that for file names too: file-1.txt, file-2.txt, file-10.txt.
How are capital letters handled?
By default capitals and small letters count as equal, so lines differing only in case keep their original relative order, as Item 1 and item 1 do. Turn on case-sensitive sorting to separate them: b, B, a and A then sort to a, A, b, B, with the lowercase form of each letter first.
Does it sort every language correctly?
It follows your browser’s language rules, so accented letters sit near their base letters and non-Latin alphabets use their own collation order. Japanese kana and kanji may not appear in dictionary reading order, because the characters are compared as written rather than by how they are read.