Text Sorter
Sort lines alphabetically, by length, or numerically — with optional deduplication.
Everything runs in your browser. Nothing you type is uploaded or stored.
In-depth guide
Text sorter: order of operations, case, accents and numbers
The exact pipeline (trim, drop blanks, de-duplicate, sort), what 'ignore case' really ignores, how numeric mode treats non-numbers, and why file10 sorts before file2.
Key figures at a glance
- Pipeline order
- Trim, drop blank lines, de-duplicate, then sort
- De-duplication keeps the first occurrence in your original order.
- Sort modes
- Seven
- A to Z, Z to A, shortest, longest, numeric low-high, numeric high-low, reverse.
- Blank lines
- Always removed
- There is no control to keep them.
- Alphabetical order
- Browser locale collation
- Digits are compared as text, so file10 comes before file2.
What happens, in order
- The text is split into lines (
\r\n,\rand\nall count). - If Trim spaces is on (default), whitespace at both ends of each line is removed.
- Empty lines are dropped. This always happens, because the page has no switch for it, and a line that was only spaces counts as empty only when trimming is on.
- If Remove duplicates is on, repeated lines are removed and the first occurrence is kept. With Ignore case on, duplicates are detected after lowercasing.
- The remaining lines are sorted by the chosen mode and joined with new lines.
Because de-duplication runs before sorting, "first occurrence" means first in your original order, not first alphabetically.
Modes
| Mode | How lines are compared |
|---|---|
| A to Z / Z to A | Locale-aware text comparison (localeCompare). |
| Shortest / longest first | By string length in UTF-16 code units; equal lengths are ordered alphabetically. |
| Numeric, low to high / high to low | By the leading number of each line (parseFloat); a line without one counts as 0. |
| Reverse current order | Flips the order after the clean-up; no sorting at all. |
Ignore case also ignores accents
With Ignore case on, alphabetical comparison uses the "base" sensitivity of Intl collation, where a, A and á compare as equal. So accents are ignored too, not just capitals. Equal lines keep their original relative order because modern JavaScript sorting is stable (ECMAScript 2019).
Example input: banana, Apple, cherry, blank line, apple, Éclair, eclair, banana, Zebra, zoo.
| Options | Result |
|---|---|
| Defaults (trim, ignore case) | Apple, apple, banana, banana, cherry, Éclair, eclair, Zebra, zoo |
| Ignore case off | apple, Apple, banana, banana, cherry, eclair, Éclair, Zebra, zoo |
| Remove duplicates on | Apple, banana, cherry, Éclair, eclair, Zebra, zoo |
| Duplicates on, ignore case off | apple, Apple, banana, cherry, eclair, Éclair, Zebra, zoo |
| Trim off | cherry (with its leading spaces) comes first, before Apple |
Notice that with duplicates on, Éclair and eclair both survive: duplicate detection lowercases but does not remove accents, even though sorting treats them as equal. With ignore-case off, lowercase apple sorts before Apple in the JavaScript engine used for these examples (Node.js with ICU), but the exact order of case and accent variants depends on the browser's locale rules (Unicode collation, UTS #10), so results can differ between machines.
Numbers
Alphabetical mode compares digits as characters, not values: file1, file10, file2. Use numeric mode for lines that start with numbers.
Numeric mode reads only the start of each line. Input item10, 10, 9, 2.5, -3, 1e3, abc, $5, 7, 0x10 sorts low-to-high as -3, item10, abc, $5, 0x10, 2.5, 7, 9, 10, 1e3:
1e3is read as 1000 and-3as negative three.item10,abc,$5(leading currency symbol) and0x10(hexadecimal is read as0) all count as 0, so they stay together in their original order, between-3and2.5.
Strip currency symbols and thousands separators first: 1,200 is read as 1.
Other edge cases
- Length mode and emoji. Length counts UTF-16 code units, so
😀has length 2, the same asaband你好. Tamilதமிழ்has length 5 because it is five code points (consonants, vowel signs and the virama each count). - Mixed scripts. Latin, Chinese and Tamil lines can be ordered differently on different systems because the order of scripts comes from the browser's collation data.
- No natural sort. The tool does not treat
10as bigger than2inside text likefile10.
Common mistakes
- Sorting a list with
Ignore caseon and expectingÉclairandeclairto be considered different. - Using alphabetical mode on numbers and getting
10before9. - Expecting blank lines to be kept. They are always removed.
- Expecting duplicates to be merged when they differ by an invisible trailing space and trimming is off.
Related tools
Comma separator turns a sorted list into a comma-separated string. Remove line breaks cleans blank lines without sorting. Text diff compares two versions of a list. Word counter counts lines.
Frequently asked questions
Is my text sent to a server?
No. Everything runs in your browser using JavaScript. Nothing you type or paste is uploaded, logged or stored anywhere.
Is there a length limit?
There is no fixed limit — the practical ceiling is your browser's memory. Documents of tens of thousands of words are handled comfortably.
Does it handle non-English text?
Yes, any text can be sorted. Alphabetical order uses your browser's locale-aware comparison, so accented letters sort next to their base letters and the order of other scripts follows your browser language. Numeric sorting reads only a leading number written with Western digits (0-9).
Does it change my original text?
No. Your input stays exactly as you typed it; the result is produced separately so you can adjust the options and compare.
Sources
- MDN — Intl.Collator sensitivity options
- MDN — Array.prototype.sort() (stability)
- MDN — parseFloat()
- Unicode UTS #10 — Collation Algorithm
This guide explains published rules in plain language. It is not financial, legal or official advice — rules change, so confirm with the agency linked above before you commit.