Skip to content

Sort lines alphabetically, numerically or naturally

Sort lines alphabetically, numerically, naturally, by length or at random, with case sensitivity, deduplication and blank-line removal.

  • Runs in your browser
  • Files are never uploaded
  • Free, no account

One item per line. Sorting happens in this tab, so even a 100,000-line list never leaves your device.

Sort method
Direction

Plain A→Z. With case sensitivity on, uppercase letters sort before lowercase ones (code-point order), which matches most command-line sorts.

Off sorts “apple” and “Apple” together.

Drops empty lines before sorting.

Strips leading and trailing spaces.

Keeps the first occurrence of each line.

Lines in
0
Lines out
0
Blank lines removed
0
Duplicates removed
0
Sorted result
Paste a list above and it will be sorted instantly.

How to sort a list of lines

  1. Paste your list, one item per line, or drop a text file onto the box.
  2. Pick a sort method. Alphabetical is the default; Natural is usually the better choice whenever your lines contain numbers.
  3. Choose ascending or descending, and turn on case sensitivity if uppercase and lowercase should be treated as different.
  4. Optionally strip blank lines, trim whitespace and remove duplicates in the same pass.
  5. Copy the result or download it as a text file.

Alphabetical vs natural vs numeric

These three produce genuinely different results and choosing the wrong one is the most common reason a sorted list “looks wrong”.

Input Alphabetical Natural Numeric
file10file1file1file1
file2file10file2file2
file1file2file10file10

Alphabetical compares character by character, so “1” sorts before “2” and file10 lands before file2. Natural sort reads runs of digits as numbers, which is how Finder, Windows Explorer and human beings order filenames. Numeric ignores the text entirely and sorts by the first number found on each line — the right choice for “Item 4 — 128 units” style rows where you care about the leading figure. Lines with no number stay together at the end.

Case sensitivity and locale

With case sensitivity switched on, comparison is by Unicode code point: every uppercase ASCII letter sorts before every lowercase one, so Zebra precedes apple. That is identical to LC_ALL=C sort on the command line, and it is what you want when reproducing a machine-generated ordering.

With it off, comparison uses your browser’s locale collator, which sorts “apple, Apple, Äpfel, banana” the way a dictionary in your language would. That is the friendlier option for anything a person will read.

Stability, blank lines and duplicates

The sort is stable: lines that compare as equal keep their original relative order. This matters most for “by length” and numeric sorting, where ties are common — the ten seven-character lines stay in the order you typed them.

Blank-line removal happens before sorting, so empty rows do not all pile up at the top. Deduplication also happens before sorting and respects the case-sensitivity setting, keeping the first occurrence of each value.

Shuffling

“Shuffle” uses a Fisher–Yates shuffle driven by a seeded pseudorandom generator, which gives every permutation an equal chance. Press Reshuffle for a new seed. It is useful for randomising a question bank, picking a running order, or assigning reviewers — though for a prize draw you should use a method you can audit and publish.

Everything runs locally

Lines are collected in chunks so that even a list of several hundred thousand rows sorts without locking up the tab, and nothing is uploaded. That makes it safe for customer identifiers, internal hostnames and anything else you would not paste into a server-side tool.

Questions

What is natural sort?

Natural sort compares digit runs as numbers, so "file2" comes before "file10". Plain alphabetical sorting compares character by character and puts "file10" first, because "1" is lower than "2".

What happens to lines without a number in numeric mode?

They are grouped at the end in their original order, so nothing disappears. Numeric mode reads the first number on the line, including negatives and decimals.

Is the sort stable?

Yes. Lines that compare as equal keep their original relative order, which matters when you sort by length or by a leading number.

Does case sensitivity change the result?

With case sensitivity on, uppercase letters sort before lowercase ones (code-point order), matching the Unix sort command in the C locale. With it off, "apple" and "Apple" sort together using your browser locale rules.