Skip to main content

Text Sorter

Sort lines alphabetically, remove duplicates, trim whitespace and drop blank lines in one pass. Runs in your browser with nothing uploaded.

Paste a list, one item per line, and sort it ascending or descending while optionally removing duplicates, trimming surrounding whitespace and dropping blank lines. The line counts before and after show exactly how much was removed.

Text Sorter
The result appears here...

// Text Sorter: Features

Four operations, one pass

Sorting, deduplicating, trimming and dropping blanks are almost always wanted together, because the lists that need sorting are usually lists that were assembled by hand or pasted from somewhere untidy. Doing them in one pass avoids the sequence of manual steps where the trimming gets forgotten and the deduplication then fails to spot two entries that differ only by a trailing space.

Trim before you deduplicate

This is the ordering that matters. Two entries that look identical but differ by a leading or trailing space are different strings, so deduplication leaves both. Enabling trim along with deduplication catches them, which is why a list that appeared to have no duplicates suddenly loses several lines once trimming is on. The before and after counts make that visible rather than surprising.

How the sort order is decided

Sorting uses locale-aware comparison rather than raw code point order, which produces the result a reader expects: accented characters sort next to their unaccented equivalents rather than after Z, and Japanese sorts by reading. Raw code point order, which naive sorting uses, puts all upper-case letters before all lower-case ones and scatters accented characters far from their base letters.

What sorted lists are actually for

Making two lists comparable is the commonest reason: a sorted list diffs cleanly against another sorted list, while the same content in different orders produces a diff full of noise. Beyond that, sorting makes a long list scannable, surfaces near-duplicates by placing them adjacent, and produces a stable order for anything that will be reviewed or committed to version control.

Sorting addresses and hostnames without uploading them

The sorting happens in your browser, so lists of email addresses, internal hostnames, customer identifiers and unreleased feature names can all be processed without being transmitted, stored or logged. To compare the sorted result against another list, the Diff Checker shows what differs line by line.

// Text Sorter: FAQ

What does it do?

Sorts lines ascending or descending, and optionally removes duplicate lines, trims leading and trailing whitespace from each line, and drops blank lines. The counts above and below the output show how many lines went in, how many came out and how many were removed.

Why did deduplication miss obvious duplicates?

Almost certainly whitespace. Two lines that look the same but differ by a trailing space are different strings. Turn on trim as well as deduplicate and they will collapse. Invisible characters such as a non-breaking space pasted from a web page have the same effect and are harder to spot.

Is the sort case-sensitive?

Sorting uses locale-aware comparison, which treats upper and lower case as adjacent rather than separating them entirely. That produces the ordering a reader expects, unlike raw code point sorting, which places every capital letter before every lower-case one.

How are accented and non-Latin characters ordered?

Sensibly, because the comparison is locale-aware. Accented Latin characters sort beside their base letters rather than after Z, and Japanese and other scripts sort according to their own conventions rather than by code point.

Can it sort numbers correctly?

Numbers in a text list sort as text, so 10 comes before 2 because the character 1 precedes 2. This catches people out with version numbers and identifiers. Pad the numbers with leading zeros to a common width if you need numeric order from a text sort.

Does it preserve the original order of equal lines?

Sorting is stable, so lines that compare as equal keep their relative order. This matters mainly when the lines differ in ways the comparison ignores, such as case in some locales.

Can I sort by something other than the whole line?

No, the comparison uses the whole line. To sort by a field within each line, rearrange the lines so the sort key comes first, sort, then rearrange back. The bulk replacement tool in the Japanese edition can do both steps with a regular expression.

What counts as a blank line?

A line with no characters, and with trimming enabled, a line containing only whitespace. That distinction is worth knowing: without trimming, a line of three spaces is not blank and survives the drop-blank-lines option.

Is there a limit on list length?

No fixed limit. Very long lists recalculate on every change and may feel slow, but lists of tens of thousands of lines are handled comfortably.

Is the list I sort sent to a server?

No. Sorting and deduplication run in your browser, and the list is never transmitted, stored or logged.

// How to Use Text Sorter

  1. Paste your list

    Put one item per line into the input box. The line count beside it confirms how many entries the tool has read.

  2. Choose the operations

    Pick ascending or descending, and enable deduplication, trimming and dropping blank lines as needed. Enabling trim alongside deduplication catches entries that differ only by invisible whitespace.

  3. Check the counts, then copy

    Compare the output line count against the input. A larger drop than you expected usually means duplicates you did not know about; a smaller one usually means trimming was needed.

Category Text