Sort lines of text

Put a list in order: A to Z, Z to A, natural number order, shortest first, by the number on each line, or shuffled.

Sort lines of text

0 characters

Three steps — nothing to install

  1. Paste the list

    One item per line. Leading spaces are ignored for comparison but kept in the output.

  2. Pick the order

    Alphabetical, natural, numeric, length, reversed, shuffled, or drop duplicates while sorting.

  3. Copy the result

    The sorted list is ready to copy or download; nothing is uploaded.

Natural order versus character order

A plain character sort puts item 10 before item 2, because the character 1 comes before 2. That is technically correct and almost never what people mean. Natural order compares the runs of digits as numbers, so item 2, item 9, item 10 come out in the order a person reads them.

Sorting uses the browser's locale-aware collator, so accented letters sort next to their unaccented forms and case is ignored when you ask for it. That also means the exact order of punctuation differs slightly between languages, which is correct behaviour rather than a bug.

Sorting by a number on the line

The numeric modes read the first number they find on each line, so 12 apples sorts as twelve and 2.5 kg sorts as two and a half. Thousands separators are ignored. Lines with no number at all go to the end, because there is no honest place to put them in a numeric order.

If the number you want to sort by is not the first one, split it out first — with the find and replace tool or a spreadsheet — then sort. Guessing which number matters is how sort tools produce surprising results.

Shuffling, duplicates and ties

Shuffle uses the browser's cryptographic random generator and a Fisher–Yates shuffle, so every ordering is equally likely. That matters for sampling a list or drawing names; a Math.random shuffle is good enough for a playlist and not for a draw.

Modern browsers keep equal elements in their original order when sorting, so ties stay stable. The de-duplicate option removes repeated lines during the sort, which is a quick way to turn a messy export into a clean one. For a dedicated pass, use remove duplicate lines.

Frequently asked questions

Can I sort case-insensitively?Yes. Tick Ignore capitalisation and A/a sort together, with ties keeping their original order.
Does it remove duplicates?It can. Tick the option and duplicates are dropped as the list is sorted; otherwise every line is kept.
What does natural sort do?It compares numbers as numbers, so item 2 comes before item 10 instead of after it.
Is the shuffle fair?Yes. It uses the browser's cryptographic random generator, not Math.random, and every permutation is equally likely.
How are blank lines sorted?They sort as empty strings, which puts them at the top in ascending order. Remove them first if you do not want that.
Is anything uploaded?No. Sorting happens on the strings in this tab, with no server request.