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 `Zebra` sorts before `apple`. 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 `ä` after `z`, German sorts it with `a`, 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 Text Tools tools
Case Converter
Convert between Sentence, Title, camelCase, snake_case, and more.
Word Counter
Count words, characters, and analyze keyword density.
Text to Binary
Convert text into its 8-bit binary representation.
Binary to Text
Decode 8-bit binary back into readable text.
Text Reverser
Reverse text by characters, words, or lines.
Remove Duplicate Lines
Delete repeated lines and keep your list unique.
Remove Empty Lines
Strip blank and whitespace-only lines from text.
Sort Lines Alphabetically
Sort lines A–Z or Z–A, case-sensitive or not.