Text Sorter — Sort Lines
Sort lines of text alphabetically, numerically or by length — with case-insensitive matching, trimming, de-duplication and reverse, all live.
Paste a list, choose an order — alphabetical, numeric or by length — and get sorted lines instantly, with options to trim, de-duplicate and clean as you go. Free. No sign-up. Runs in your browser, nothing is uploaded.
Sort order
Paste a list with one item per line, pick A → Z, Z → A, 0 → 9, 9 → 0 or By length, and the sorted version appears below as you type. Five switches clean the list on the way — trim, case-insensitive, remove duplicates, remove empty lines and reverse — and three counters show how many lines went in, came out and were dropped.
Cleaning a messy list in one pass
Say you paste a list exported from two sources:
banana
Apple
apple
cherry
banana
With A → Z, Case-insensitive, Trim whitespace, Remove duplicate lines and Remove empty lines on, the output is:
Apple
banana
cherry
Six lines in, three out, three removed: the blank line, the lowercase apple and the second banana. Duplicates keep their first occurrence, which is why Apple survives rather than apple — if you care which spelling wins, put the preferred one higher in the input. If you only want repeats gone and the original order kept, Remove Duplicate Lines does just that without sorting.
Why "Item 10" lands before "Item 2"
Alphabetical sorting compares text character by character, and the character "1" comes before "2" — so Item 10 sorts before Item 2, and file100.jpg before file20.jpg. That isn't a bug; it's how A → Z works everywhere.
Numeric mode fixes it only when the number comes first on the line. 10 Item and 2 Item sort as 2, 10. Item 2 and Item 10 don't start with a number, so numeric mode treats them as text and you get the same alphabetical order. The practical fix is to pad numbers with zeros (Item 02, Item 10), which sorts correctly in any mode and in any other program too.
What numeric mode counts as a number
The tool reads the number at the very start of each line, ignoring leading spaces, and ignores whatever follows it:
| Line | Read as | Note |
|---|---|---|
12 apples | 12 | Text after the number is ignored |
-3.5 °C | −3.5 | Signs and decimal points work |
1,250 | 1250 | Groups of exactly three digits after a comma are thousands |
1,250,000 | 1250000 | Any number of such groups |
1,250.75 USD | 1250.75 | Thousands groups, then a decimal point |
1,5 kg | 1.5 | Any other single comma between digits is a decimal comma |
1,2500 | 1.25 | Four digits after the comma are not a thousands group |
1,5,2 | 1 | Two commas that aren't thousands groups: reading stops at the first |
1.250 | 1.25 | A period is always a decimal point |
$12 | not a number | Starts with a symbol — goes to the end |
Total: 40 | not a number | Number isn't at the start |
The comma rule is fixed, so you can predict every line: a comma followed by exactly three digits, repeated as often as needed and not followed by another comma, is a thousands separator; any other single comma is a decimal comma. The one case it can't tell apart is a German-style decimal with three places, so 1,250 meaning one and a quarter is read as 1250. German thousands with points (1.250,50) are not recognised either, since the point counts as a decimal point; replace them with plain digits (1250,50) before sorting. Lines that aren't numbers are grouped at the end in both 0 → 9 and 9 → 0, sorted alphabetically among themselves. Lines with the same number keep the order they had in your input.
Capitals, accents and the case-insensitive switch
A → Z uses your browser's language-aware comparison, not raw character codes. In practice that means:
é,äandñsort next toe,aandn, not afterz.- Even with the switch off,
appleandApplesit next to each other instead of all capitalised words coming first, as they would in a strict computer sort. - Case-insensitive treats
Appleandappleas equal: the two then stay in the order you pasted them, and only one survives "Remove duplicate lines".
If you need a list to be consistently capitalised before you sort it, run it through the Case Converter first.
The order the switches run in
The options aren't applied all at once, and the sequence explains some results:
- Trim strips spaces at the start and end of each line (on by default). Without it,
appleandappleare different lines. - Remove empty lines drops blank lines and lines containing only spaces, even if trim is off.
- Remove duplicates keeps the first occurrence, using the trimmed text and the case setting.
- Sort by the chosen order. "By length" counts characters and breaks ties alphabetically.
- Reverse flips the finished list. Used with 9 → 0, it puts the non-numeric lines at the top.
Frequently asked questions
Related tools
All Text & Writing tools →- Remove Duplicate LinesDelete duplicate lines from any list or text, with trim, case and sort options — instantly in your browser.
- Word & Character CounterCount words, characters, sentences, paragraphs and reading time as you type.
- Case ConverterConvert text to UPPERCASE, lowercase, Title Case or Sentence case — instantly, in your browser.
