Skip to the content

Sort & Dedupe Lines

Sort a list, remove duplicates, shuffle it or number the lines.

Lines in
0
Lines out
0
Duplicates
0
Share this tool:TwitterFacebookLinkedInWhatsAppEmail

What happens to your list, and in which order

Every step is optional, but they always run in this order: spaces around each line are trimmed, empty lines are dropped, duplicates are removed, the lines are sorted, and only then are numbers, a prefix and a suffix added. Because numbering comes last, the numbers run from 1 without gaps, whatever was removed before.

A to Z or natural order

A to ZNatural order
file1.txtfile1.txt
file10.txtfile2.txt
file2.txtfile10.txt

A to Z compares character by character, and the character 1 comes before the character 2, so file10 ends up before file2. Natural order reads every run of digits as one number. That is what you want for file names, chapters, house numbers and version numbers.

The catch is that natural order knows nothing about decimals. In 1.25 it sees the numbers 1 and 25, so 1.5 sorts before 1.25. For prices and measurements use By number instead. It goes by the first number in each line (3.5 and 3,5 both work, and -4 is smaller than 2) and puts lines without a number at the end.

Both alphabetical orders follow the rules of an English dictionary. Capitals and accents only decide between lines that are otherwise the same, so éclair sorts next to eclair and not after zebra. Alphabets with an order of their own are not followed: in Swedish ä comes after z, here it sorts with a.

What counts as a duplicate

Two lines are duplicates when they are the same, character for character. Apple and apple are different lines, and so are apple and apple followed by a space. Switch on Trim spaces and Ignore case to treat those as the same. The first one is kept as it was written, the later ones go.

The counter shows the number of duplicates even when you leave them in, which is a quick way to check a list without changing it.

If two lines look identical and still aren't counted, they differ in something you can't see: another kind of apostrophe, a no-break space, an invisible character. The Text Cleaner removes those.

How the shuffle works

Shuffle uses the Fisher-Yates method with numbers from your browser's cryptographic random generator, the same source that is used for encryption keys. Every possible order is equally likely. A new order is drawn when you press Shuffle again, and also when the number of lines changes.

See all 9