Search tools

Sort Lines Alphabetically, by Number or Length

Paste one item per line and it is sorted A to Z as you type, in natural order so 2 comes before 10 (file1.txt, file2.txt, file10.txt). Switch to Z to A, sort by the number in each line, by length, by last word or by a CSV column, remove duplicates, or shuffle the list at random.

Updated By Rules checked 5 November 2026Examples

Sort lines

6 lines · 9 words · 41 characters

6 lines sorted.

Advertisement

How to sort lines

  1. Paste your list, one item per line.
  2. Choose the order: A to Z, Z to A, by number, by length, or press Shuffle.
  3. Choose what to sort by: the whole line, the last word, or a column of CSV or tab-separated data.
  4. Copy or download the sorted list. Tick Remove duplicates to clean it in the same step.

Sort orders compared

The sample list in each order
OrderResult
A to Z, natural (default)apple
Banana
Cherry
Item 1
item 2
Item 10
Z to AItem 10
item 2
Item 1
Cherry
Banana
apple
A to Z, plain text order (10 before 2)apple
Banana
Cherry
Item 1
Item 10
item 2
Case-sensitive (capitals first)apple
Banana
Cherry
Item 1
item 2
Item 10
Shortest to longestapple
Banana
Cherry
Item 1
item 2
Item 10
Reverse the current orderCherry
Item 1
apple
Banana
item 2
Item 10

Advertisement

Numbers, surnames and columns

Worked examples
LinesOptionResult
RM1,200 rent
RM 85 phone
RM 1,050.50 car
RM-5 refund
Numbers, smallest firstRM-5 refund
RM 85 phone
RM 1,050.50 car
RM1,200 rent
Siti Aminah
Ahmad Zaki
Lim Wei
Last wordSiti Aminah
Lim Wei
Ahmad Zaki
Ali,32
Bala,25
Chong,41
Column 2, comma, numbersBala,25
Ali,32
Chong,41

How the sorter compares lines

  • Collation: the browser's Unicode collation (Intl.Collator) for English or Malay, so accented letters sort next to their base letter (é with e) instead of after z.
  • Case: ignored by default; Case-sensitive puts capitals before lowercase for the same word (A, a, B, b).
  • Ties: lines that compare equal keep their original order (stable sort).
  • Numbers: the first number in the line or column is used; "1,050.50" is one thousand and fifty point five.

Note: Excel and Google Sheets sort numbers stored as text in plain character order (10 before 2). If your sorted list will go back into a spreadsheet, sort it there by a number column, or keep Natural order on here.

Sources

Frequently asked questions

How do I sort lines alphabetically?

Paste your text with one item per line: it is sorted A to Z as you type, ignoring upper and lower case, and empty lines are removed. Choose Z to A to reverse it. Copy the result or download it as a .txt file.

Why does 10 come before 2 in other sorters?

Plain character order compares one character at a time, and "1" comes before "2", so you get file1.txt, file10.txt, file2.txt. Natural sort reads whole numbers, giving file1.txt, file2.txt, file10.txt. Natural order is on by default; untick it if you need strict character order.

How do I sort numbers or prices?

Choose Numbers, smallest first (or largest first). Each line is sorted by its first number, so text around it is fine: "RM1,200 rent" sorts after "RM 85 phone". Commas as thousands separators, decimals and minus signs are understood; lines without a number go to the end.

Can I sort names by surname?

Choose Sort by last word. "Siti Aminah", "Ahmad Zaki" and "Lim Wei" sort as Aminah, Wei, Zaki. Malay names with bin or binti and Chinese names with the family name first are better sorted on the whole line, since the last word is not the family name.

How do I sort CSV data by a column?

Choose Sort by column, pick the separator (comma, tab, semicolon, pipe or space) and the column number. "Ali,32", "Bala,25" and "Chong,41" sorted by column 2 as numbers become Bala, Ali, Chong. A header row is sorted with the data, so cut it first and paste it back.

How do I shuffle lines randomly?

Press Shuffle. It uses the Fisher-Yates method, so every order is equally likely; press again for a new order. For a fair draw with a spinning wheel, use the Spin the Wheel tool.

Is my text saved or uploaded?

Nothing is uploaded: sorting runs in your browser. Your last text is kept in this browser's local storage so it survives a reload; Clear removes it. Only the options go into the page address, so a shared link opens with the same sort settings.

Advertisement