Text Sorter: Sort Lines Alphabetically or by Length
By TheToolsBank Editorial TeamLast updated:
How to sort a list of lines
- Paste your list into the box. Each line counts as one item.
- Choose a sort order: A to Z, Z to A, shortest to longest, or longest to shortest.
- Leave Case-insensitive on (the default) unless capital letters must be treated as different from lowercase.
- Tick Natural sort (numbers in order) if your lines contain numbers, so 2 comes before 10.
- Tick Remove duplicates if you want each line to appear only once, and Remove empty lines to drop blank lines.
- Select Sort, then Copy result to paste the list where you need it.
The tool splits your text at each line break. A comma-separated list counts as one line, so put each item on its own line first.
The four sort orders
| Sort order | What it does | Example result |
|---|---|---|
| A to Z | Alphabetical order using your browser's language rules | apple, Banana, cherry |
| Z to A | The A to Z order reversed | cherry, Banana, apple |
| Shortest to longest | Orders lines by character count, spaces included | fig, kiwi, mango |
| Longest to shortest | The same count, largest first | mango, kiwi, fig |
Alphabetical sorting uses your browser's language-aware comparison. Accented letters sort with their plain letters, so "éclair" lands among the E words. Capital and small letters are treated alike, so "Banana" sits between "apple" and "cherry".
Sorting numbers and numbered items
By default the tool compares lines as text, one character at a time, so "10" and "100" come before "2". Tick Natural sort (numbers in order) and groups of digits are compared as whole numbers instead.
| Your list | A to Z result | With Natural sort |
|---|---|---|
| 2, 10, 100, 1 | 1, 10, 100, 2 | 1, 2, 10, 100 |
| item2, item10, item1 | item1, item10, item2 | item1, item2, item10 |
Natural sort works on A to Z and Z to A; the length orders ignore it. It reads whole numbers, not decimals: in 1.5 and 1.25 it compares 5 with 25, so 1.25 lands after 1.5. Pad decimals to the same length (1.50, 1.25) to fix that.
Removing duplicate lines while sorting
When Remove duplicates is ticked, the tool keeps the first copy of each line and drops later copies, then sorts what is left. With case-insensitive on, "Apple" and "apple" count as the same line and only the first one you pasted is kept. Turn case-insensitive off if you need to keep both.
A line with a trailing space does not match one without it, so it stays. If you only need to clean a list and keep its original order, use the Remove Duplicate Lines tool instead.
Common uses
- Alphabetize names for a class roster, guest list, or bibliography.
- Sort keywords, tags, or email addresses and remove repeats in one pass.
- Make two lists easier to compare by sorting both the same way.
To make capitalization consistent before you sort, run the list through the Case Converter first.
Common Mistakes to Avoid
Sorting numbers with Natural sort turned off.
Solution:
Leaving blank lines or a trailing line break in the list.
Solution:
Having stray spaces at the start of lines.
Solution:
Removing duplicates with case-insensitive on when case matters.
Solution:

