Sort & Dedupe Lines

Sort a list alphabetically, naturally or numerically, drop duplicates, filter it, or shuffle it — with a count of what changed.

Input
Result

Alphabetical order is not what you meant

Sort a list of filenames or version strings alphabetically and you get v10 before v9, and item2 before item10. That is not a bug in the sort — it is the sort doing exactly what it was told. Comparing character by character, 1 sorts before 9, so 10 lands between 1 and 2.

Natural sort splits each string into runs of digits and runs of non-digits, then compares digit runs numerically. It is what humans expect when they say "sort by name", and it is why file explorers, version listings and anything with numbered items need it rather than a plain string comparison.

InputAlphabeticalNatural
file1, file10, file2file1, file10, file2file1, file2, file10
v9, v10, v100v10, v100, v9v9, v10, v100
a1b, a10b, a2ba1b, a10b, a2ba1b, a2b, a10b

Locale-aware sorting is a separate axis

Even after you fix the numbers, plain comparison still sorts by Unicode code point, which means accented characters sort after z in many cases and Ä does not sit next to A. Intl.Collator applies locale rules, so ä sorts near a in German and the ordering is what a speaker of that language expects.

The catch is that locale collation is slower and, importantly, not stable across locales. If you are sorting for display, use the user's locale. If you are sorting to produce a canonical order that must match on another machine — a checksum, a diff, a deterministic build — use a fixed comparison and document it.

Deduplication is less obvious than it looks

Three decisions hide inside "remove duplicates", and getting them wrong silently loses data:

  • Case — is Admin the same as admin? For an email list, yes. For a case-sensitive identifier, no.
  • Whitespace — trailing spaces make two otherwise identical lines distinct. Trimming first is almost always what you wanted.
  • Which copy survives — if lines carry meaning by position, keeping the first occurrence and keeping the last give different results.

This tool trims and drops empties before comparing, so the count it reports is the count of things a human would call distinct.

Sorting a million lines in a browser

Everything here runs on the main thread, which is fine up to a few hundred thousand lines. Past that, the page will freeze for a second or two. The fix is a Web Worker, but for the lists people actually paste into a text box — a few thousand entries — the simple version is both faster and easier to trust, because there is no worker to synchronise.

Frequently asked questions

Why does my numeric sort put 10 before 9?

Because the mode is still alphabetical. Choose "Numeric sort" to compare by value, or "Natural sort" to handle lines that mix text and numbers.

Can I sort by column?

Not with this tool. It treats each line as one unit. For tabular data, convert to CSV first and sort in a spreadsheet.

Is the shuffle cryptographically random?

No. It uses Math.random, which is fine for shuffling a list of demo data and useless for anything adversarial. Use the password generator for anything where unpredictability matters.

Does my text get uploaded?

No. Sorting happens in this page with no network request, so lists of internal hostnames or customer identifiers are safe to process here.

Privacy. Every operation runs locally. Paste a server inventory, a list of email addresses or a stack of log lines — it never leaves the browser.