Sort lines of text

Sort lines or list items alphabetically, naturally, by length or at random, with optional de-duplication.

Runs in your browser. Your input is not uploaded.

Loading the tool…

What it does

Sorting splits the input into items, orders them and joins them again. Items can be separated by new lines, commas, tabs, semicolons, spaces or blank lines, and the output separator can differ from the input, so the same tool turns a comma list into one item per line.

Alphabetical order uses your browser’s locale collation, so accented letters sort next to their base letter. Natural order compares runs of digits as numbers, so file2 comes before file10.

How to use it

  1. Paste the list.
  2. Choose how items are separated and the order.
  3. Tick Remove duplicates or Reverse if you need them, then copy the result.

Example: Natural order

Input
file10.txt
file2.txt
file1.txt
Output
file1.txt
file2.txt
file10.txt

Things to watch for

  • Plain alphabetical order puts 10 before 2. Use natural order for anything with numbers in it.
  • Duplicates are compared after trimming when Trim is on, so a and a count as the same item.
  • Random order uses the browser’s secure random source and a Fisher–Yates shuffle, so every order is equally likely.

Questions

How do I sort a comma-separated list?
Set the input separator to Comma (or Comma and space) and choose an output separator. The output can stay comma-separated or become one item per line.
Is the sort case-sensitive?
Not by default: apple and Apple sort together. Tick Case-sensitive to put upper case first and to treat them as different when removing duplicates.
Can I sort by line length?
Yes. Choose Length. Items of equal length are then sorted alphabetically.
Does this sort numbers numerically?
Natural order does. It reads each run of digits as a number, so 9, 10, 100 stays in that order.