Sort lines alphabetically
Alphabetical sorting that puts item2 before item10, the way you expect.
Runs in your browser0 bytes uploadedAlphabetical sorting that puts item2 before item10, the way you expect.
Runs in your browser0 bytes uploadedNothing at the counter yet.
Plain alphabetical sorting compares one character at a time. It reaches the1 in item10 and the 2 in item2, sees that 1 comes before 2, and stops there. The rest of the number never gets looked at.
That is technically correct string ordering and almost never what anyone wants. It is why file managers used to list chapter1, chapter10,chapter11, chapter2 — and why every operating system eventually added natural sorting instead.
Natural ordering reads runs of digits as numbers rather than as characters, soitem2 sorts before item10. It is on by default here. Turn it off if you specifically need raw string order — comparing against a database index, for example, where the database is doing plain comparison and you need to match it.
Sorting by raw character codes puts Swedish å, ä andö somewhere after z — which happens to be correct for Swedish, and entirely by accident. It also puts é in a position no French speaker would expect, and Ø nowhere near where a Dane would look.
This tool uses locale-aware comparison rather than character codes. Accented letters sort next to their base letter where that is the convention, and Swedish letters sort at the end of the alphabet where they belong.
Sorting is case-insensitive, so apple and Apple land next to each other rather than in two separate blocks. Raw character-code sorting puts every capitalised word before every lowercase one, which splits an alphabetical list into two alphabetical lists — technically sorted, practically useless.
They are removed. A sorted list beginning with fourteen empty lines is not a useful result, and blank lines carry no ordering information. Lines are trimmed of leading and trailing whitespace before comparison, so a stray space from a copy-paste does not push a line to the top.
Plain alphabetical sorting compares character by character, and the character "1" comes before "2". Natural sorting reads runs of digits as numbers instead, which puts item2 first. It is on by default here.
Yes. Sorting uses the browser locale comparison rather than raw character codes, so Swedish letters sort after z rather than in the middle of the Latin range.