Sort lines
Sort lines. Runs entirely on your device, nothing is uploaded.
Runs on your device. The file is never uploaded.
Sort lines reorders the lines of a text file and changes nothing inside them. order defaults to asc, numeric to false, caseSensitive to true. The alphabetical comparison is raw code unit order, so digits sort before capitals and capitals before lowercase. Switch numeric on and parseFloat reads each line, calling anything without a leading number 0.
Questions
What order does the alphabetical sort use?
Plain code unit order, not a language-aware collation. Lines are compared with less-than and greater-than on the raw strings, so digits come before uppercase letters, uppercase before lowercase, and accented letters land after z. Turn caseSensitive off and both sides are lower-cased before comparing, which puts Apple next to apple. There is no locale setting, so the result does not change with your browser language.
How does numeric sorting handle lines that are not numbers?
It treats them as zero. With numeric on, each line is run through parseFloat and the two values are subtracted, so 12px sorts as 12, and a line of text with no leading number sorts as 0. Numbers embedded later in the line are ignored, because parseFloat only reads from the start. Leave numeric off and 10 sorts before 9, which is correct alphabetically and usually not what you wanted.
How do I sort largest first?
Set order to desc. The tool always sorts ascending first and then reverses the whole array, which also reverses the relative order of lines that compared equal. order defaults to asc. Combining desc with numeric gives you biggest number first; combining it with the alphabetical comparison gives you z to a.
Why is there a blank line at the top of my sorted output?
Because a file ending in a newline produces one final empty line when it is split, and an empty string sorts before everything else. It is your file's trailing newline arriving as data. Delete it after sorting, or run Whitespace cleanup first. The tool does not silently drop empty lines, since in a list of values a blank entry can be meaningful.
Does sorting change the lines themselves?
No. Lines are reordered and nothing else. Case folding and numeric parsing happen inside the comparison only; the text written out is exactly the text that came in. The one change is the separator: input is split on CRLF or LF and rejoined with LF, so a Windows file comes back with Unix line endings.