Skip to content
Text

Sort & Dedupe Lines

Paste a list and reshape it. Sorting is natural, so item2 comes before item10 rather than after it, and deduplication can ignore case and surrounding whitespace.

0 in · 0 out · 0 duplicates

Press Esc to clear

Result

Options

About the Sort & Dedupe Lines

A list of lines is the most common shape data arrives in: a column pasted out of a spreadsheet, a set of filenames, a list of email addresses, the output of a command. The operations you want on it are always the same handful, and none of them are worth opening an editor or writing a script for.

Sorting here is natural rather than lexicographic. A plain string sort puts item10 before item2, because it compares character by character and 1 comes before 2. That is correct by the letter and wrong by every human expectation, and it is the single most common complaint about other line-sorting tools. This one uses the browser's own collation with numeric ordering switched on, so numbered items sort the way you would sort them by hand. Numeric mode goes further and reads the first number out of each line, so a mixed list still orders correctly and lines with no number sink to the bottom rather than scattering through the results.

Deduplication keeps the first occurrence of each line and can compare case-insensitively or ignore surrounding whitespace, which matters when a list has been assembled by hand and half the entries have a trailing space. It can also be inverted to show you only the lines that appeared more than once, which is how you find the duplicates rather than remove them.

Shuffling uses a Fisher-Yates shuffle, so every ordering is equally likely — unlike the sort-by-random trick, which is subtly biased. Everything runs locally and nothing is uploaded.

Frequently asked questions

Why does item2 sort before item10 here but not elsewhere?

Because this tool uses numeric collation. A plain string sort compares character by character, so it sees the 1 in item10 before the 2 in item2 and orders them wrongly. Numeric collation reads runs of digits as numbers, which is how a person sorts.

Can I find the duplicates instead of removing them?

Yes. Turn on "show duplicates only" and the output is the lines that appeared more than once, listed once each, rather than the deduplicated list.

Is the shuffle actually random?

It uses a Fisher-Yates shuffle, in which every possible ordering is equally likely. The common alternative of sorting by a random comparator is measurably biased toward certain orderings.