Sort Lines Tool
Sort lines of text alphabetically, numerically, by length, or in reverse.
About This Tool
You have a list of 200 names, a CSV column you copied out, or a chunk of imports at the top of a file, and you need them sorted. Pasting them into a spreadsheet feels overkill for a one-off, and your editor's sort-lines command works for some use cases but not others — case sensitivity, numeric sorting, and reverse order each need their own keyboard shortcut.
Paste lines, pick a sort method (alphabetical, numerical, by length, reverse), and get them back sorted. Duplicates can be kept or removed. Numerical sort handles the case where alphabetical comparison would put "item10" before "item2" — natural sort puts them in the order a human would expect. Empty lines can be preserved or stripped depending on whether they're meaningful in your context (often they aren't).
The sort algorithms: alphabetical sort uses your browser's localeCompare, which respects Unicode and locale-specific ordering rules. Case-sensitive sort treats uppercase letters as ordering before lowercase (so "Apple" comes before "apple"); case-insensitive flattens both. Natural sort (numeric-aware) parses runs of digits as numbers, so "file2" sorts before "file10" — which matches how humans expect it but not how pure character-by-character comparison works. Length sort orders by line length, useful for finding outliers in a list of similar entries. Reverse sort is just the inversion. Dedupe operates on exact line matches; whitespace counts as significant unless you preprocess.
A worked example: paste in `apple\nBanana\ncherry\napple\ndate`. Alphabetical case-insensitive: apple, apple, Banana, cherry, date. With dedupe: apple, Banana, cherry, date. Now try natural sort on `item1\nitem10\nitem2\nitem20`. Pure alphabetical: item1, item10, item2, item20 (because "1" < "2" character-wise). Natural: item1, item2, item10, item20 (correct human ordering). Most file managers default to natural now precisely because the alphabetical result is so jarring.
Where line-based sorting falls short: structured data. CSV with quoted fields containing commas can't be sorted line-by-line because the lines aren't atomic units of data. Multi-line records (paragraphs separated by blank lines, JSON objects spanning multiple lines) similarly need a parser-aware tool. For sorting CSV by a specific column, paste into a spreadsheet, sort there, and copy back. For sorting JSON by a key, use jq or a similar structured tool. The line-sort approach works perfectly for unstructured lists — names, file paths, URLs, imports — and breaks down for anything where the line isn't the natural unit. Locale-specific sorting (German umlauts, Spanish ñ) follows your browser's locale settings; for cross-system reproducibility, normalize to ASCII or specify the locale explicitly. Stable sort (preserving original order for equal items) is the default for modern browsers, so duplicate-but-different entries (like two lines that compare equal but aren't identical bytes) keep their original relative order.
The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.