Skip to the tool

Sort lines

MDV Tools

Paste lines. Pick an order. Natural order reads the digits inside a line as a number, so file2 lands before file10. Lines that compare equal keep the order they came in.

Runs on this device Works offline
0 characters
Result
paste lines above
How this works

The text is split into lines at every line break; a Windows CR LF is read the same as LF and comes out as LF, and a final trailing line break is not counted as a line. A–Z and Z–A compare lines with Intl.Collator("en"), so letters fall in dictionary order rather than code-point order. Natural is the same collator with numeric: true, which reads a run of digits as one number and puts file2 before file10. Ignore case sets the collator's sensitivity to accent: a and A tie, while e and é stay apart. By length compares the count of UTF-16 code units, so a character outside the Basic Multilingual Plane counts as two. Every order goes through Array.prototype.sort, which is stable in every current engine — lines that compare equal keep their input order. Z–A is A–Z with the comparison inverted, not the result reversed, so ties still keep input order.

Trim before comparing strips leading and trailing whitespace from the comparison key only; the lines themselves come out untouched. A blank line is one that is empty or only whitespace. Remove duplicates keeps the first occurrence in input order and judges sameness on the comparison key — trimmed if trim is on, lowercased with toLowerCase if ignore case is on. No Unicode normalisation is applied anywhere, so a precomposed é and an e followed by a combining accent are two different lines. Shuffle is one Fisher–Yates pass drawing every index from crypto.getRandomValues with rejection sampling, so no position is favoured; there is no seed, so an order cannot be reproduced — press Shuffle again for a fresh one. Reverse flips the current line order and sorts nothing.

Input above 2,000,000 characters is refused rather than attempted, so the tab never hangs. Nothing is uploaded: there is no server in this file.

The Dark button remembers its setting in this browser's local storage. Nothing you type or drop into the page is stored.