Alphabetize and sort lines of text any way you need.
Paste a list and sort it alphabetically, in reverse, by length, or numerically. Sorting looks simple until you meet numbers stored as text, accented characters or mixed case — each of which produces a result that is technically correct and completely unhelpful.
A naive sort compares character codes, which puts all uppercase letters before all lowercase ones because A is 65 and a is 97. That gives:
rather than the case-insensitive ordering most people expect:
Proper alphabetical sorting uses locale-aware collation, which also places accented characters next to their base letters rather than after Z, and applies language-specific rules — in Swedish, for instance, certain accented vowels sort after Z as distinct letters rather than alongside A and O. This tool uses the browser's built-in collator, which follows Unicode collation rules rather than raw character codes.
This is the trap that catches everyone. Sorting numbers as strings compares them character by character, so 10 comes before 9 because 1 is less than 9:
| String sort | Numeric sort |
|---|---|
| 1, 10, 100, 2, 20, 3 | 1, 2, 3, 10, 20, 100 |
| file1, file10, file2 | file1, file2, file10 |
| v1.10, v1.2, v1.9 | v1.2, v1.9, v1.10 |
The numeric mode handles plain numbers. For mixed strings like file10, what you want is natural sort, which recognises digit runs inside text and compares them as numbers — the ordering file managers use so that chapter2 precedes chapter10.
The version-number row is a related and slightly different problem: version strings need each dot-separated component compared numerically and independently, which is why 1.10 is a later release than 1.9 despite being a smaller decimal.
| Mode | Behaviour | Good for |
|---|---|---|
| A to Z | Locale-aware alphabetical | Names, words, general lists |
| Z to A | Reverse alphabetical | Newest-first labels |
| Numeric | Compares values, not characters | Figures, IDs, quantities |
| By length | Shortest to longest | Finding outliers, cleaning data |
Sorting by length is more useful than it sounds for data cleaning — unusually short or long entries in a column of supposedly uniform values are usually the malformed ones.
A leading space sorts before every letter, so lines that look like they belong together end up separated at the top of the output. Since whitespace is invisible, this is a confusing failure. Trim your lines before sorting if the list came from a copy and paste. Blank lines likewise cluster at the start of an ascending sort.
A stable sort keeps equal elements in their original relative order. This matters when sorting the same list repeatedly on different keys: sort by surname, then by department, and a stable sort leaves each department's surnames still alphabetical. An unstable sort would scramble them. JavaScript's sort has been required to be stable since ES2019, so results here are stable and repeated sorts compose predictably.
Sorting runs in your browser with no upload. That is worth noting because sorted lists are so often personal data — names, email addresses, customer records. You can verify it in the Network tab of your developer tools. Long lists sort quickly; the browser's built-in sort runs in n log n time, so even tens of thousands of lines complete near-instantly.
Because a text sort compares character by character, and the character "1" comes before "9". Use the numeric mode, which compares the values rather than the characters.
A raw character-code sort puts all uppercase letters before all lowercase, since A is 65 and a is 97. This tool uses locale-aware collation instead, which interleaves them the way a dictionary does.
That needs natural sorting, which detects digit runs within text and compares them numerically. A plain alphabetical sort puts file10 before file2 because it compares "1" against "2" one character at a time.
Usually leading whitespace, which sorts before every letter and is invisible. Blank lines do the same. Trim the list before sorting.
Next to their unaccented base letters, following Unicode collation rules, rather than after Z as a raw character-code sort would put them. Some languages treat certain accented letters as separate letters entirely, which locale-aware collation respects.