WordsPolish.
← All Tools

Sort Lines (A-Z, Length, Deduplicate)

Alphabetical, by-length, or dedupe-while-sorting — three distinct sort modes for list editing.

This tool runs entirely in your browser. Nothing you type or paste here is ever sent to a server — see how the calculations work.

Paste a list — one item per line — and sort it alphabetically, by line length, or alphabetically with duplicates removed in the same pass. These are three genuinely different operations useful for different tasks: alphabetizing a name list, finding your shortest or longest lines in a set of headlines or titles, or cleaning a keyword or email list that has both ordering and duplication problems at once.

The sorted list appears here as you type.

The three sort modes

Alphabetical sort compares lines using standard lexicographic (dictionary) ordering, with a case-insensitive option toggled on by default so "Apple" and "apple" sort next to each other rather than being separated by every other capitalized word in between (a case-sensitive sort would put every uppercase letter before every lowercase one, since that's how character codes are ordered, which produces a visually confusing list for mixed-case input).

Sort by length orders lines from shortest to longest (or the reverse, toggleable) by character count — useful for finding your longest headline in a batch, checking a list of titles all fit under a length limit, or just visually scanning a list from most to least concise.

Dedupe-while-sorting combines alphabetical ordering with duplicate removal in one step: it's the same as running /remove-duplicate-lines/ and then alphabetizing, but done in a single pass so you don't have to run two tools back to back for the common case of cleaning up a messy list that's both unordered and has repeats.

Who uses this

  • Alphabetizing a reference list, glossary, or bibliography before publishing.
  • Finding the longest or shortest line in a batch of headlines, product names, or form labels to check for outliers.
  • Cleaning and alphabetizing a keyword list or email list in one step rather than running separate dedupe and sort passes.

Edge cases to know about

  • Case-insensitive alphabetical sort treats "Apple" and "apple" as equal for ordering purposes, but preserves whichever original capitalization each line had — it doesn't force consistent casing across the list. Use /case-converter/ first if you also want consistent capitalization.
  • Numbers at the start of a line sort as text characters, not as numeric values, by default — so "10 items" sorts before "2 items" alphabetically (because "1" comes before "2" as a character), which can surprise users expecting numeric ordering. A natural-sort (numeric-aware) toggle handles this if your list starts with numbers.
  • Blank lines in the input are preserved during a length sort (a blank line has length zero and sorts first) but are stripped automatically during dedupe mode, since a run of blank lines is itself a form of duplicate.

Related tools

FAQ

Does sorting remove duplicate lines automatically?
Only in the specific "dedupe-while-sorting" mode. Plain alphabetical and length sorts preserve every line exactly as given, including exact duplicates, since sorting and deduplication are separate operations — use /remove-duplicate-lines/ directly if you want to dedupe without also reordering.
Why did "Item 10" sort before "Item 2" in my list?
Standard alphabetical sorting compares text character by character, so "1" is treated as less than "2" regardless of what follows — "Item 10" sorts before "Item 2" the same way "a" sorts before "b". Turn on natural (numeric-aware) sorting if you want "Item 2" to correctly come before "Item 10".
Is the sort case-sensitive?
By default no — "Apple" and "apple" are treated as equivalent for ordering, which matches how most people expect an alphabetized list to read. A case-sensitive toggle is available if you specifically need strict character-code ordering instead.
Can I preview the sorted result before replacing my original list?
Yes — the sorted output is shown separately from your input, so you can compare the two before copying the result over your original text. Nothing is overwritten automatically.
What happens to leading or trailing whitespace on each line during a sort?
Each line is trimmed of leading and trailing spaces before comparison, so a line with accidental extra spaces at the start doesn't get sorted into a different position than its trimmed content would suggest — the visible leading/trailing spaces are removed in the output as a side effect.