How to Sort Lines Alphabetically or Numerically

Sort lines alphabetically online, ascending or descending, with numeric and case-insensitive modes and optional dedupe. Get true number order, not 1, 10, 2.

Updated 5 min read By CodingEagles
Free tool Sort Lines Alphabetically Sort lines A→Z or Z→A, numerically, with optional dedupe. Open tool

To sort lines alphabetically, paste your list into a line sorter, pick ascending or descending, and copy the ordered result. For lists of numbers, switch on numeric mode so they sort by value rather than digit by digit. The free sort lines tool does it instantly in your browser, with case options and optional dedupe, nothing uploaded.

Sorting a list by hand is slow and mistake-prone past a dozen items. A sorter does it in one step, but there are two settings, numeric mode and case handling, that decide whether the result is right or quietly wrong.

A to Z, and the gotcha with numbers

Plain alphabetical sorting compares lines character by character, left to right. For words, that gives the order you expect. For numbers, it does not. Sorted alphabetically, these lines come out wrong:

1
10
2
21
3

That is because “1” comes before “2” as a character, so “10” lands right after “1”. It is technically correct alphabetical order and completely useless for numbers. Numeric mode fixes it by reading each line as a value, giving 1, 2, 3, 10, 21. Any time your lines are numbers, or start with a number you care about ordering by, switch numeric mode on.

How to sort lines

Step 1: Paste your lines

Drop in your list, one item per line, into the line sorter.

Step 2: Pick the order and mode

Choose A to Z or Z to A. Switch on numeric sorting for number lists, and case-insensitive matching if you want capitalisation ignored.

Step 3: Copy the sorted list

The list reorders instantly, with duplicates removed too if you turned that on. Copy it out.

Case-insensitive sorting, and why it usually helps

By default, many sorts put all uppercase letters before all lowercase ones, because of how characters are ordered internally. So “Banana”, “apple”, “Cherry” would sort as “Banana”, “Cherry”, “apple”, with the capitalised words bunched at the top. That is rarely what you want for a human-readable list.

Case-insensitive sorting ignores capitalisation when comparing, so the same three sort as “apple”, “Banana”, “Cherry”, in true alphabetical order regardless of case. For glossaries, name lists and most prose, leave it on. Turn it off only when capitalisation is genuinely part of the sort, which is uncommon.

Sort and dedupe in one pass

A list you are sorting often has duplicates too. Rather than sorting, then removing duplicates separately, switch on the dedupe option and do both at once. Identical lines collapse to a single entry as the list is ordered, so you end up with a clean, sorted, unique list in one step. This is the natural pairing for tags, keywords and reference lists where you want them alphabetised and deduplicated together.

Real uses

  • Glossaries and references. Alphabetise terms or sources so a reader can scan them quickly.
  • Number lists. Order IDs, prices or quantities by value with numeric mode.
  • Cleaning exports. Sort a messy export and drop duplicates before you import it elsewhere.
  • Comparing lists. Two lists are far easier to diff once both are sorted, because matching items line up.

When order must stay put

Sorting is the wrong move when the original sequence carries meaning, like ranked items or steps. If you only need to remove repeats without reordering, use an order-preserving dedupe instead. See how to remove duplicate lines while keeping order.

Frequently asked questions

Why use numeric sort instead of alphabetical?
Alphabetical sorting compares character by character, so it puts 10 before 2 because 1 comes before 2. Numeric sort reads each line as a number and orders by value, so 2 comes before 10 as expected. Use numeric mode whenever your lines are numbers or start with them.
What does case-insensitive sorting do?
It groups words regardless of capitalisation, so Banana, apple and Cherry sort as apple, Banana, Cherry rather than putting all capitalised words first. With it off, uppercase letters sort ahead of lowercase ones, which scatters related words apart.
Can it remove duplicates while sorting?
Yes. Switch on the dedupe option and identical lines collapse to one as the list is sorted, giving you a clean, ordered, unique list in a single step.
Is my list uploaded?
No. The sort runs on your own device. Nothing is sent to a server, and it works offline once the page has loaded.

Ready to try it?

Sort lines A→Z or Z→A, numerically, with optional dedupe. Free, in-browser, and 100% private — your data never leaves your device.

Open the Sort Lines Alphabetically