Alphabetical, natural and by number
Three orders look alike and give different answers once numbers are involved. Take the lines item 1, item 10 and item 2:
- Alphabetical compares character by character, like a dictionary. It puts item 1, item 10, item 2, because it compares one character at a time and 1 comes before 2.
- Natural reads a run of digits as one number. It gives item 1, item 2, item 10, which is what a file manager does. It also puts version numbers in the right order: 1.9 comes before 1.10.
- By number sorts on the first number found in each line, whether it is at the start or in the middle. It handles negative numbers, decimals with a dot, and thousands separators such as 1,200. Lines without a number go last, in their original order. It reads 1.10 as the decimal 1.1, so use Natural for versions.
Language rules and capital letters
With Follow language rules on, letters are ordered the way a language orders them. Switch it off and lines are compared by plain Unicode order, in which every capital letter comes before every small one and accented letters come after z. In that order Zebra sorts before apple, and éclair sorts after zebra.
- English and most others: an accented letter sits next to its plain letter, so a, á and b come in that order.
- Swedish: å, ä and ö come after z.
- Danish: æ, ø and å come after z.
- Spanish: ñ is a separate letter after n.
- German: ä sorts with a, as in most dictionaries.
- Turkish: the dotless ı and the dotted i are different letters with their own places.
Case sensitive is off by default. Then Apple and apple count as the same letters, and equal lines keep the order they had. Turn it on and capitals are told apart: in language order a comes before A, and in plain order every capital comes first.
Length, reverse and shuffle
By length sorts on the number of characters in each line. Characters are Unicode code points, not bytes, so an accented letter stored as one character (é) counts once, while a letter followed by a separate accent mark counts twice. Lines of the same length keep their original order. Reverse flips the order, so the last line comes first. It is the quick way to turn a log that has its newest line at the bottom upside down.
Shuffle puts the lines in a random order using the Fisher-Yates method with your browser's secure random number generator, so every order is equally likely. Press Shuffle again for a new one. It is good for a speaking order, a playlist or a set of flashcards. It is not a verifiable draw, so do not use it where people need to be able to check the result.
Cleaning the list while you sort
- Trim spaces around each line stops stray spaces from changing the order. A line with a leading space would otherwise sort before the others.
- Remove empty lines drops blank lines, so they do not collect at the top.
- Remove duplicate lines keeps the first copy of each. Case sensitivity decides what counts as the same. For counts and more control, use the duplicate line remover.
- Ignore bullets and list numbers sorts as if a leading dash, bullet or number such as 3. was not there. The lines keep it.
- Ignore a leading The, A or An files The Great Gatsby under G, as libraries and indexes do. It is for English only.
The sort is stable: lines that compare as equal keep the order they had. For a plain A to Z list with the list friendly defaults already set, open alphabetize a list.