What is a text sorter?
A text sorter puts the lines of a block of text in order. Paste a list with one item per line, such as names, keywords, file names or numbers, and the tool sorts it alphabetically from A to Z or Z to A, numerically in either direction, or shuffles it into a random order. Each line moves as a whole and its text isn't changed.
How to sort lines
- Paste the lines you want to sort into the input box.
- Pick a Sort Order: Alphabetical (A-Z), Alphabetical (Z-A), Numeric (ascending), Numeric (descending) or Random.
- Click Convert and copy the sorted list.
Worked example: alphabetical
Input:
banana
Apple
cherry
apple
Éclair
eclair
item10
item2
Zebra
Alphabetical (A-Z) output:
Apple
apple
banana
cherry
Éclair
eclair
item10
item2
Zebra
Three things are going on here. Apple and apple count as the same word, so they stay in the order they were pasted. Éclair sorts with the e's rather than after Zebra, because accents are ignored too. And item10 lands before item2, because the comparison is character by character and "1" comes before "2".
Z-A mode sorts in the opposite direction, starting with Zebra, but lines that compare equal still keep their pasted order: Apple then apple, and Éclair then eclair.
How alphabetical order is decided
The tool compares lines with JavaScript's localeCompare() at "base" sensitivity, using your browser's language settings. Base sensitivity means only the underlying letter counts: case and accents are ignored.
Using the browser's language matters for some alphabets, because sort order is a rule of each language, set out in the Unicode Collation Algorithm and its per-language tailorings:
| Line | English or German browser | Swedish browser |
|---|---|---|
| ä | sorts with a | sorts after z |
| Ø | sorts with o | sorts after z (also in Danish and Norwegian) |
So two people sorting the same list can get slightly different results if their browsers are set to different languages. Both are correct for their language.
Worked example: numeric
Numeric mode reads the number at the start of each line. Leading spaces, one currency symbol (such as $, € or £) and comma thousands separators are skipped, so prices and large figures sort by their value. Here's a messy list sorted with Numeric (ascending):
| Line | Value used for sorting |
|---|---|
| -$5 | -5 (sign before the currency symbol) |
| -3 | -3 |
| abc | 0 (doesn't start with a number) |
| 0.25 | 0.25 |
| 7 | 7 |
| 9.5 | 9.5 |
| 10 | 10 |
| $20 | 20 (currency symbol skipped) |
| 100 kg | 100 (unit ignored) |
| € 1,200.50 | 1200.5 |
| 1,500 | 1500 (thousands separator skipped) |
| 2e3 | 2000 (scientific notation) |
The output is in exactly that order, and Numeric (descending) gives the reverse. In alphabetical mode the same list would put 10 and 100 kg before 2e3 and 7, since it compares characters, not values.
A comma only counts as a thousands separator when exactly three digits follow it, so 1,500,000 is 1500000 but 1,5 (a European decimal comma) is read as 1. Change decimal commas to points first with find and replace if your list uses them. Lines with equal values keep their original order in both directions.
Random order
Random mode shuffles the lines with the Fisher-Yates algorithm, so every possible order is equally likely, and clicking Convert again gives a new shuffle. It uses Math.random(), which is fine for shuffling a playlist or a list of quiz questions but isn't meant for draws where fairness has to be provable.
Tips
- Remove duplicates after sorting. Sorting keeps every line. Remove Duplicate Lines keeps the first copy of each, and the result stays sorted.
- Fix capitalization separately. The sort ignores case but doesn't change it. Use the case converter if you want the list in one consistent case.
- Watch for hidden spaces. A leading space is a character like any other, so
zebra(with a space) sorts beforeapplealphabetically. - Comparing two lists? Sort both the same way, then compare them in the code diff tool to see what's missing from each.
Everything runs in your browser, so lists with names or email addresses aren't uploaded anywhere.
Last updated