What it does
This is a general line sorter. It takes one item per line and returns the same items in a new order. Unlike a spreadsheet sort, it works on plain text that you can paste from anywhere, and unlike a one-line command, it lets you choose the comparison without remembering a flag.
There are three keys: the whole line, the last word, and one field from a delimited row. Each can run ascending or descending. Blank lines, duplicates, surrounding spaces, and a header row are handled by explicit options rather than silent guesses. The output is text, so it can go back into a document, a code block, or another tool.
Sort modes
Whole line is the ordinary alphabetical sort. It compares the complete line with the browser’s collation rules, which means letters with accents and letters in other scripts are ordered sensibly rather than by raw code point. Punctuation is not ignored, so a line beginning with a quote will sort near other punctuation.
Length is handled separately. If shortest-first or longest-first is the task, use Sort Lines by Length. That page measures visible characters with grapheme clusters, keeps equal lengths in a stable alphabetical order, and has its own controls for headers and blank lines.
Last word splits on whitespace and compares the final token. It is a quick way to sort names written as “First Last” without rearranging them, or to group filenames by extension when the extension is the last token. It is whitespace-based, not a name parser.
Delimited column splits each line by the separator you provide and compares one field. Column numbers start at 1. A missing field sorts as an empty value. This is a line-level sort, not a full CSV parser: a quoted delimiter inside a field is still treated as a separator here.
Ties, case, and numbers
Natural number ordering compares runs of digits as numbers, so item 2 comes before item 10. Turn it off for a strict character comparison, which is sometimes what a machine-readable identifier needs. The case-sensitive option changes the collator’s sensitivity; the output always keeps the original capitalization.
Trimming removes spaces and tabs from both ends of each line before comparison and writes the trimmed line to the output. That makes “ Apple” and “Apple” compare equally, but it also removes intentional indentation. Remove-empty and dedupe are separate switches. Dedupe keeps the first line in the sorted result, not necessarily the first line in the input.
Examples
Before
Ada Lovelace,Research,London
Grace Hopper,Engineering,New York
Alan Turing,Research,ManchesterAfter
Ada Lovelace,Research,London
Alan Turing,Research,Manchester
Grace Hopper,Engineering,New YorkThe last word is the city in this data, so the rows end up in London, Manchester, New York order. The names themselves are not rearranged. If a row has no spaces, its only word is also its last word, which makes the mode safe for single-token lists.
Before
Ada Lovelace,Research,London
Grace Hopper,Engineering,New York
Alan Turing,Research,ManchesterAfter
Grace Hopper,Engineering,New York
Ada Lovelace,Research,London
Alan Turing,Research,ManchesterEngineering sorts before Research, and the two Research rows keep their relative input order. If the first row were a header, “Keep the first line as a header” would hold it in place and sort only the data below it. The output is still a line-oriented text block, not a rewritten CSV file.
Before
item 10
item 2
item 1After
item 1
item 2
item 10With natural ordering off, the same input becomes item 1, item 10, item 2, because the character “1” in 10 sorts before “2”. Neither order is wrong; they answer different questions.
Limits worth knowing
- It sorts lines, not records. A newline inside a quoted CSV field becomes a separate line. Use the delimited column extractor for quoted rows before sorting if the file contains multiline fields.
- Column mode is simple splitting. It does not unquote fields, respect escaped delimiters, or understand a header schema. A comma inside a quoted name still splits the row. That trade-off keeps the tool predictable for logs and simple exports.
- Collation depends on the browser. The ordering uses the runtime locale, so two machines can differ on edge cases involving accents, punctuation, or language-specific alphabets. For a byte-stable order, use a dedicated program with an explicit locale.
- Dedupe is not a merge. It drops later copies and keeps the first one in the sorted result. It does not combine fields or choose the “best” duplicate.
- Trimming changes the output. The option is convenient for pasted lists and destructive for indented code. Leave it off when leading whitespace is content.
Page updated