Sort Lines Alphabetically or Numerically Online
Sort lines of text alphabetically, in reverse, numerically, or by line length. Optionally trim whitespace and drop empty lines.
How to use Sort Lines
- Paste your list with one item per line — names, tasks, numbers, file paths, or any values.
- Leave "Trim whitespace" and "Drop empty lines" on to clean the list before sorting (recommended for most lists).
- Pick a sort: A → Z or Z → A for text, Numeric for figures, By length for shortest-to-longest, or Reverse to flip the current order.
- Read the sorted result in the output box and adjust the toggles if blank lines or stray spaces affected the order.
- Click Copy to grab the sorted list. The ordering is computed in this tab, so a list of private names or internal data never leaves your screen.
Sorting a list of lines
Putting a list in order is a deceptively common chore: alphabetising names, ranking numbers, tidying imports, or arranging tags. Spreadsheets can do it but require pasting into a column first, and most code editors only offer a basic A → Z. This tool gives you five sort modes plus cleanup options, all on the raw lines you paste, with the result one click away.
Alphabetical sorting that respects language
The A → Z and Z → A modes use locale-aware comparison, so accented and non-English letters sort the way a human would expect rather than by raw byte value. This avoids the classic bug where "Zoë" or "Ångström" lands in a surprising place because its accented character has a high code point.
Numeric vs alphabetical: a crucial difference
Sorting numbers alphabetically gives the wrong answer: "100" comes before "9" because the comparison is character by character. Numeric mode parses each line as a number, so 2, 9, 10, and 100 sort in true order. Always pick numeric mode for prices, quantities, IDs, scores, or any column of figures.
The same list, three different sorts
It helps to see one input run through each mode. Take these five lines:
9
100
2
Ångström
apple- A → Z (locale-aware) orders them
100, 2, 9, Ångström, apple. The numbers sort as text — "100" comes before "2" because1precedes2— while the accentedÅfiles next to plainarather than being banished to the end by its high code point. - Numeric reads each line with
parseFloat, givingÅngström, apple, 2, 9, 100. The two word lines parse as 0 and sink to the bottom, and the figures finally sort by value so 100 lands after 9 — the whole reason numeric mode exists. - By length ranks by character count:
9, 2, 100, apple, Ångström(1, 1, 3, 5, 8 characters), with equal-length lines keeping their original relative order.
The takeaway: if your lines mix words and numbers, decide first whether you are sorting them as labels (A → Z) or as quantities (Numeric), because the two produce visibly different results on the very same data.
Sort by length and reverse
By length orders lines from shortest to longest, which is great for finding outliers or arranging items by size. Reverse simply flips the current order of the lines without otherwise sorting them — useful when your data is already in a meaningful sequence and you just need it inverted.
Clean before you sort
The Trim whitespace and Drop empty lines toggles handle the two things that most often spoil a sort. Trailing spaces make otherwise identical lines sort apart, and blank lines clump at the top of an alphabetical sort. Leaving both on produces the clean, predictable ordering you usually want; turn them off only when the whitespace or blank lines carry meaning.
A note on duplicates
Sorting groups duplicates together but does not remove them. If your goal is a clean, unique, ordered list, dedupe first and then sort — the two tools are designed to be used together.
Related text tools
- Remove Duplicate Lines — strip repeats before sorting.
- Reverse Text — flip line order without sorting by value.
- Extract Emails — pull addresses out, then sort them here.
- Word & Character Counter — measure the list you just sorted.
Frequently asked questions
What does the A → Z sort use under the hood?
How does numeric sort handle non-numbers?
Why does alphabetical sort put 100 before 9?
What is "By length" useful for?
Will sorting remove duplicate lines?
What do the trim and drop-empty toggles change?
Can it sort thousands of lines?
Is my list sent to a server?
Related tools
More tools you might find useful in the same flow.
Remove Line Breaks
Remove line breaks from text online — strip every newline, collapse extra spaces, or replace each break with a custom separator. Free, instant, no signup.
Word Counter
Word counter online: count words, characters, sentences, and paragraphs in real time, with reading and speaking time estimates. Free, and no signup needed.
Remove Duplicate Lines
Remove duplicate lines from text online — paste a list and get a deduped version instantly, with case-sensitive or insensitive matching. Free and private.
Find & Replace
Find and replace text online with plain search or full regex support, case-insensitive matching, and a live count of matches. Free, and nothing is uploaded.
Built by Muhammad Tahir · About