Line sorter

Sort lines, drop duplicates, or reverse line order in your browser.

Docify's line tool splits on LF after turning CRLF and CR into LF, then drops a single trailing empty field from a final newline. Sort uses Array.prototype.sort with no compare function (UTF-16 code units — not localeCompare). Unique keeps the first line for each Set key. Reverse is reverse() on that array. Ignore case keys with toLowerCase(). Actions are buttons, not as-you-type. Not a natural sort and not Unix sort. Nothing is uploaded.

Lines
Output

How it works

  1. Sort, Unique, and Reverse are buttons, not as-you-type. Load sample fills the input only. Copy writes the output. Nothing is uploaded.
  2. Lines are split after \r\n and \r become \n. A trailing empty field from a final newline is dropped. Internal blank lines stay. Lines are not trimmed.
  3. Sort is Array.prototype.sort() (UTF-16 code units). Unique keeps the first hit in a Set. Reverse is reverse() and does not sort. Ignore case uses toLowerCase() as the compare or Set key. Output is joined with LF.
  4. This is not localeCompare, not a natural/numeric sort, not Unix sort, and not a CSV column sorter.

FAQ

Does this tool upload my text?
No. Sort, Unique, Reverse, and copy run in your browser. The page does not send the text to a server.
How are lines split?
CRLF and lone CR become LF, then the string is split on LF. A single trailing empty field from a final newline is dropped so "a\nb\n" is two lines, not three. Internal blank lines stay. Lines are not trimmed.
What order does Sort use?
Array.prototype.sort with no compare function — UTF-16 code-unit order from ECMA-262. Uppercase letters sort before lowercase because A is code unit 65 and a is 97. This is not localeCompare, not Intl.Collator, not Unix sort, and not a natural/numeric sort (so "10" sorts before "2"). Ignore case compares toLowerCase() keys and keeps the first original line when those keys match (stable sort).
How do Unique and Reverse work?
Unique walks the line array and keeps the first occurrence of each key in a Set. The default key is the exact line; Ignore case uses toLowerCase(). Reverse calls Array.prototype.reverse on that same line array and does not sort. Output is lines joined with LF. There is no trailing newline added, no column sort, and no as-you-type update.

Related