Skip to tool
ecech.
✏️ Text & SEO Content

Sort and Deduplicate Lines, Including the Ones That Only Look Identical

A plain sort puts 10 before 9. A plain dedupe keeps two lines that differ by a trailing space. Both are shown and both are fixable here.

In

Out

Duplicates removed

Blanks removed

Result



Things you cannot see in your text

Advertisement

How the calculation works

The same list, two sorts alphabetical item10 item2 item9 character by character natural item2 item9 item10 digit runs as numbers Alphabetical is what a computer does by default. Natural is what you meant.

How to Use This Tool

Paste your lines and pick what to do with them. Every option reports how many lines it changed, so a surprising result is visible rather than silently accepted.

Natural versus alphabetical

A default sort compares strings character by character, so "1" comes before "9" and therefore item10 comes before item2. That is correct string ordering and almost never what anyone wants for a list containing numbers.

Natural sort treats runs of digits as numbers, giving item2, item9, item10. It is what file managers do, what people expect, and what a plain sort call does not give you. If your list has version numbers, filenames or anything ending in a counter, this is the option you want.

Lines that look identical and are not

Deduplication compares exact strings, so anything invisible defeats it:

  • Trailing spaces. "banana " and "banana" are different, and nothing on screen shows why they both survived.
  • Non-breaking spaces. Text copied from a web page or a Word document often contains U+00A0 instead of a normal space. It looks identical and compares differently.
  • Line endings. A file from Windows uses carriage return plus line feed; one from Unix uses line feed alone. Mixed files leave stray carriage returns on some lines.

The panel at the bottom counts each of these in your text. Turning on "trim each line" fixes the first two for comparison purposes, which is why it is on by default.

Why the duplicate survived banana 6 characters banana· 7 characters — a trailing space Identical on screen, different to every string comparison ever written.
The most common reason a deduplicated list still has duplicates in it.

Case sensitivity is a choice about your data

Apple and apple are different strings and usually the same thing. Which behaviour you want depends on what the lines are:

  • Ignore case for names, tags, keywords, email addresses — anywhere the capitalisation is incidental.
  • Respect case for identifiers, file paths on a case-sensitive filesystem, and anything a computer will compare later.

When ignoring case, the first occurrence is the one kept, so the capitalisation of your output depends on the order of your input. That is worth knowing before you assume it picked the "right" one.

Shuffling

The shuffle uses Fisher-Yates, which gives every ordering equal probability. The obvious alternative — sorting with a random comparator — is measurably biased, and this site has a separate tool demonstrating exactly how much. If you are shuffling something that matters, the method is not a detail.

Advertisement

Frequently Asked Questions

Why does my sort put item10 before item2?
Because a default sort compares character by character, and "1" is less than "2". That is correct string ordering and rarely what you want for a list containing numbers. Natural sort treats digit runs as numbers and gives item2, item9, item10.
Why are there still duplicates after removing them?
Almost always an invisible difference — a trailing space, a non-breaking space pasted from a web page, or a stray carriage return from a Windows file. The lines look identical and compare differently. Trimming each line before comparing fixes the common cases.
What is a non-breaking space and why does it break things?
A different character from a normal space, U+00A0, used to stop text wrapping. Web pages and word processors insert it freely, so pasted text often contains them. It looks exactly like a space and is not equal to one in any comparison.
Should deduplication ignore case?
It depends on the data. Ignore case for names, tags and keywords where capitalisation is incidental; respect it for identifiers and file paths where it is meaningful. When ignoring case, the first occurrence is kept, so your output's capitalisation depends on input order.
What is natural sort?
Sorting that compares runs of digits as numbers rather than as characters, so file2 comes before file10. It is what file managers do and what people expect from anything with a counter in it — version numbers, filenames, ticket references.
Is the shuffle fair?
Yes — it uses Fisher-Yates, which gives every possible ordering equal probability. The common shortcut of sorting with a random comparator is measurably biased and can leave the first item in place far more often than chance would.
Is my text sent anywhere?
No. Everything happens in your browser and nothing is transmitted.

Related tools in Text & SEO Content

Browse all Text & SEO Content tools
A handwritten note reading ecech.com resting on the keyboard used to build the site.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.