Sort Lines

Sort a list A to Z, Z to A, naturally (2 before 10) or by length, and drop duplicates or blank lines.

Lines

One item per line

Sorted

Options

Sorted lines appear here as you type.

Runs in your browser — nothing you enter leaves this device.

About this tool

What it does

Sort Lines puts a list in order, one item per line: alphabetically from A to Z or Z to A, in natural order so that “chapter 2” comes before “chapter 10”, or from the shortest line to the longest. It can also reverse the order a list is already in, or shuffle it. Sorting follows the rules of language rather than computer codes, so “éclair” sits next to “eagle” instead of after “zebra”, and capitals don’t jump ahead of small letters unless you ask them to. At the same time it can drop repeated lines and blank lines, and trim stray spaces, so a list pasted from a spreadsheet, an email or a chat comes out clean in one step.

How to use it
  1. Paste your list into the box, one item per line, or press Try an example.
  2. Choose an order: A to Z, Z to A, Natural, Shortest first, Reverse or Shuffle.
  3. Turn on Remove duplicates, Remove empty lines or Trim each line if your list needs tidying too.
  4. The sorted list appears as you type. Copy it, download it as a text file, or press the swap button to keep working on the result.
Limits and your data
  • Alphabetical order follows your browser’s language settings. Most languages agree on the basics, but a few letters sort differently from one language to another — in Swedish, for example, “ö” comes after “z”.
  • Natural order treats each run of digits as a whole number. It doesn’t read decimals, dates or version numbers like 1.10 and 1.9 as numbers, so check those by eye.
  • Shortest first counts what you see, so an emoji or a Devanagari conjunct counts as one character; lines of the same length keep alphabetical order.
  • Duplicates are found after ignoring capitals (unless capitals sort apart) and, by default, the spaces at the ends of each line. The first copy of each line is kept.
  • The result keeps your line endings, Windows or Unix, and a final newline if the list had one.
  • Sorting happens in your browser. The list isn’t uploaded or saved anywhere, and it’s gone when you leave the page. Shuffling uses your browser’s own random number source.

Questions

Why does “10” come before “2” in A to Z?

Alphabetical order compares text one character at a time, and “1” comes before “2”. Choose Natural to read whole numbers as numbers, so 2 comes before 10 — the order you want for file names, chapters and invoice numbers.

How do I sort a list and remove duplicates at the same time?

Turn on Remove duplicates and choose your order. The bar under the result says how many lines were removed. To remove duplicates while keeping the original order, use Remove Duplicate Lines instead.

Is the shuffle really random?

Yes. Every possible order is equally likely: it uses the Fisher–Yates method with your browser’s cryptographic random source. Press Shuffle again for a new order — handy for picking turns, teams or a winner.

Can I sort by a column of a CSV file?

This tool sorts whole lines. To sort a spreadsheet by one column, open the file in CSV Viewer and press that column’s heading.