Sort Lines

Quick answer: Sort any list alphabetically, by number, by length, or reverse its order. Accented letters sort where readers expect them, and “file2” comes before “file10”.

Updated

Your text is processed entirely in this browser and is never sent to a server.

How to sort lines

  1. Paste your list with one item per line.
  2. Choose a mode (alphabetical, numeric, length or reverse) and a direction, ascending or descending.
  3. Adjust case sensitivity, duplicate removal and empty-line removal, then copy the result.

Examples

Alphabetical, accents sorted with their base letter

Before

Zoë
Émile
Adam
elena

After

Adam
elena
Émile
Zoë
Alphabetical with natural number order

Before

file10.txt
file2.txt
File1.txt

After

File1.txt
file2.txt
file10.txt
Numeric, ascending (line without a number goes last)

Before

Rome 14
Oslo -3
Lisbon (no data)
Madrid 9
Reykjavik -1

After

Oslo -3
Reykjavik -1
Madrid 9
Rome 14
Lisbon (no data)
By length, ascending

Before

banana
pear
fig
apple
kiwi

After

fig
kiwi
pear
apple
banana

When to use it

  • Alphabetize names, glossary terms or a bibliography.
  • Order prices, scores or measurements copied from a report.
  • Sort file names or version labels in natural order.
  • Find the shortest or longest keywords, titles or product names.
  • Reverse a log or a chronological list so the newest entries come first.

How each sort mode works

Alphabetical sorting uses the browser’s language-aware collation (Intl.Collator) with English rules on this page. Accented letters sort next to their base letter, so “Émile” comes after “elena” instead of after “Z” as in a plain code-point sort. Numbers inside lines are compared by value, so “file2” comes before “file10”. Sorting is case-insensitive by default; turn on “case sensitive” to treat uppercase and lowercase as different.

Numeric sorting uses the first number found in each line. Negative numbers such as -3 are supported and “.” is the decimal separator, so “1,5” is read as 1 and “1,250” as 1, not as 1.5 or 1250. Lines without any number are placed at the end. Length sorting counts visible characters, so an emoji counts as one, and lines of equal length are ordered alphabetically.

Reverse mode simply flips the original order without comparing lines, so the direction setting does not apply. Empty lines are removed by default, and duplicates can be removed in the same step; to remove duplicates without changing the order, use the Duplicate Line Remover instead.

Frequently asked questions

Why does “file10” come after “file2”?

Alphabetical mode uses natural ordering, which compares numbers inside text by their value instead of digit by digit. Most people expect this order for file names and versions.

Can I sort numbers that use a comma as the decimal separator?

Not directly. Numeric mode reads “.” as the decimal separator. Replace decimal commas with periods first, or the part after the comma is ignored.

Will sorting change the text of my lines?

No. Lines are only reordered. The only lines removed are empty ones (when that option is on) and duplicates (when you enable it).

Can I sort by a specific column of a CSV?

No. Each line is sorted as a whole. In numeric mode, the first number in the line decides its position.