# 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.

- Tool: [Text Sorter](https://toolsg.com/en/text-sorter)
- Language: en (available: en, zh, ms, ta)
- Last verified against official sources: 2026-10-18
- Source site: ToolSG — a planning guide, not official or financial advice. Cite the agencies listed under Sources.

## Key figures at a glance

| Fact | Value | Source |
| --- | --- | --- |
| 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

1. The text is split into lines (`\r\n`, `\r` and `\n` all count).
2. If **Trim spaces** is on (default), whitespace at both ends of each line is removed.
3. 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.
4. If **Remove duplicates** is on, repeated lines are removed and the first occurrence is kept. With **Ignore case** on, duplicates are detected after lowercasing.
5. 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`:

- `1e3` is read as 1000 and `-3` as negative three.
- `item10`, `abc`, `$5` (leading currency symbol) and `0x10` (hexadecimal is read as `0`) all count as 0, so they stay together in their original order, between `-3` and `2.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 as `ab` and `你好`. 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 `10` as bigger than `2` inside text like `file10`.

## Common mistakes

- Sorting a list with `Ignore case` on and expecting `Éclair` and `eclair` to be considered different.
- Using alphabetical mode on numbers and getting `10` before `9`.
- 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](https://toolsg.com/en/comma-separator) turns a sorted list into a comma-separated string. [Remove line breaks](https://toolsg.com/en/remove-line-breaks) cleans blank lines without sorting. [Text diff](https://toolsg.com/en/text-diff) compares two versions of a list. [Word counter](https://toolsg.com/en/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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator)
- [MDN — Array.prototype.sort() (stability)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
- [MDN — parseFloat()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat)
- [Unicode UTS #10 — Collation Algorithm](https://www.unicode.org/reports/tr10/)
