Text Sorter
Sort lines alphabetically, by length, or remove duplicates. Instant, private, no sign-up.
Input
Output
Lines: 0Characters: 0
How to sort text lines online
Paste any block of text and choose a sort method: alphabetical A→Z or Z→A, by line length (shortest or longest first), reverse the current order, or deduplicate lines while keeping the first occurrence of each. Case-insensitive sorting and whitespace trimming are optional. Output updates instantly. For more text operations, try Text Find & Replace or Remove Duplicate Words.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Alphabetising a list pasted from several sources before deduplicating it.
- Sorting lines by length to find the outliers quickly.
- Reversing a list to get the most recent entries first.
- Sorting and deduplicating a list of values in one pass.
- Ordering a list before diffing it against another.
Frequently Asked Questions
- Why is alphabetical sorting harder than it looks?
- Because a naive byte sort is not alphabetical. ASCII puts all uppercase before all lowercase, so 'Zebra' sorts before 'apple'. Real alphabetical order needs locale-aware collation, which is what Intl.Collator provides.
- How does locale change the result?
- Substantially. Swedish sorts å, ä and ö AFTER z while German sorts them with a, o and u; Spanish once treated ch as a single letter. There is no single correct order — only correct-for-a-locale.
- What is natural sort order?
- Sorting embedded numbers by value rather than by character, so file2 comes before file10. A plain string sort puts file10 first because '1' precedes '2' — which is why file listings often look wrongly ordered.
- Is the sort stable?
- Yes — equal items keep their original relative order, which is guaranteed by the ECMAScript spec since ES2019. That matters when sorting by one field after another, since it is what makes multi-pass sorting work.
- How is a numeric sort different?
- It parses each line as a number, so 9 sorts before 10. A string sort compares character by character and puts 10 first. Mixed content forces a choice about what non-numeric lines mean.
- Why do uppercase letters sort before lowercase by default?
- Because a naive comparison uses code point order, where every uppercase letter precedes every lowercase one — so
Zebrasorts beforeapple. A locale-aware comparison fixes it, and is what a human expects. - How are accented characters ordered?
- By locale, and the locales genuinely disagree. Swedish sorts
äafterz, German sorts it witha, and both are correct for their readers — which is why there is no single right ordering to fall back on.
Common errors and gotchas
- Sorting numeric lines as text, where 10 sorts before 9.
- Assuming case-insensitive ordering, which differs between implementations and changes the result.
- Sorting lines whose order carried meaning, such as a sequence of steps.
- Overlooking leading whitespace, which sorts before letters and scatters the list.
- Sorting non-English text with an ASCII comparison, which misplaces accented characters.
Related tools
Text Repeater
Repeat any text a chosen number of times.
Text to Bullet Points
Convert paragraphs to bullet points — split by sentence, period, or custom delimiter. Format for Markdown, HTML, or plain text.
RegExp Tester
Test regular expressions and inspect matches locally.
Find and Replace Text
Find and replace text, with optional regex and flags.
Text Diff / Compare
Side-by-side or unified line/character diff comparison tool.
Remove Special Characters
Strip special characters, symbols, and punctuation from text with custom options.
Em Dash Remover
Replace em dashes, en dashes, smart quotes, curly apostrophes, and ellipsis with plain ASCII equivalents.
Character Frequency Analyzer
Count the frequency of each character or word in your text.