Sort Lines Alphabetically, by Number or by Length

Paste a list, pick how to sort it, and copy the result. Remove duplicates and blank lines in the same step.

Your list and sort options

Options

How to sort lines of text

  1. Paste your list into Lines to sort, one item per line. Clear text empties the box.
  2. Choose Sort by: alphabetical, numerical, length, reverse the current order, or random shuffle.
  3. Set the options: Trim spaces around each line, Remove blank lines, Remove duplicates, Ignore upper and lower case and Natural order (2 before 10).
  4. Press Copy sorted lines. In random mode, Shuffle again gives a new order.

How each sort works

The tool trims, removes blank lines and removes duplicates first (keeping the first copy of each line), then sorts what is left. If you untick Remove blank lines, the blank lines sort to the top.

Worked example

The sample list has six lines: banana, apple, cherry, date, apple, elderberry. With the defaults (Alphabetical, Trim, Remove blank lines, Ignore case and Natural order on) the tool shows "6 lines in, 6 lines out." and:

apple
apple
banana
cherry
date
elderberry

Tick Remove duplicates and the second apple goes, giving "6 lines in, 5 lines out. Removed 1 duplicate." For prices, the lines $30, $5, $120 and $7 sort by Numerical (low to high) into $5, $7, $30 and $120.

Limits and edge cases

Numerical sorting reads only the first number, so 2024-05-06 sorts as 2024, and a period is always the decimal point, so 1.234,56 is read as 1.234. For ISO dates use Alphabetical. Dictionary order follows your browser's language, so letters such as ΓΆ can sort differently in Swedish and German. The text stays in your browser and is not uploaded. To reverse only the order of the lines use the Text Reverser, to number the sorted result use the Line Number Adder, and for duplicates alone try the Duplicate Line Remover.

Frequently asked questions

How do I alphabetize a list?

Paste the list into Lines to sort, leave Sort by on Alphabetical (A to Z) and copy the result. Tick Remove duplicates if the list repeats items.

Why does 10 sort before 2?

Plain alphabetical sorting compares one character at a time, and 1 comes before 2. Keep Natural order ticked so digits are read as whole numbers and item 2 comes before item 10.

How do I sort numbers with commas or dollar signs?

Choose Numerical (low to high). The sorter ignores thousands commas and currency symbols, so $5, $7, $30 and $120 sort in that order and 1,000 counts as one thousand.

How do I remove duplicates while sorting?

Tick Remove duplicates. The first copy of each line is kept, and with Ignore upper and lower case ticked, Apple and apple count as the same line.

Is the shuffle really random?

It is a fair shuffle: every order is equally likely. The tool uses a Fisher-Yates shuffle driven by your browser's random number generator, and Shuffle again gives a new order.