Skip to content
Server-sideDeleted in 30 minutes

Sort Lines of Text

Sort a list five different ways: alphabetically using proper language rules, naturally so that numbers inside the text order by value, by line length, by raw code point when you need to match what a programming language does, or shuffled into a repeatable random order.

Use this without the search next time. Prathom Workbench puts Prathom's tools in your toolbar.

Add to Chrome — free
Input
Result

What it does

  • Language-aware alphabetical sorting via Intl.Collator
  • Natural sort that orders embedded numbers by value
  • Sort by length, raw code point, or repeatable shuffle
  • Optional trimming and blank-line removal

How to use Sort Text Lines

  1. 1

    Paste your list

    One item per line. The list sorts shortly after you stop typing, so you can paste, compare orderings, and copy without pressing anything.

  2. 2

    Choose an ordering

    Alphabetical suits most lists. Pick Natural when your items contain numbers, and Code point when you need to reproduce a programming language's default sort.

  3. 3

    Adjust the details

    Reverse flips the result. Case sensitivity, trimming, and blank-line removal each change what is compared rather than how it is ordered.

  4. 4

    Copy or download

    Take the sorted list to your clipboard or save it as a .txt file.

How it works

Four of the five orderings are genuinely different algorithms rather than variations on one.

Alphabetical and Natural both use Intl.Collator, this server's implementation of the Unicode Collation Algorithm. This is what makes the result match a dictionary rather than a byte comparison — it knows that punctuation is usually ignorable, that case is a secondary consideration rather than a primary one, and that the correct position of accented letters depends on the language. Natural mode additionally switches on numeric collation, which detects runs of digits and compares them as numbers.

Code point deliberately bypasses all of that and compares UTF-16 values directly. It exists so you can reproduce what sort in Python, Java, or a Unix shell will do, which is occasionally exactly what you need to debug.

By length sorts on character count, breaking ties alphabetically. The tie-break matters: without it, equal-length lines would come out in whatever order the engine's sort happened to leave them, and the result would not be reproducible.

Shuffle uses a xorshift generator seeded from a hash of your input, then a Fisher-Yates pass. Seeding from the input is what makes the output stable while you are still typing.

Why natural sort is the one people actually want

Almost every complaint about a sorted list is really a complaint about numbers. Chapter 10 appearing between Chapter 1 and Chapter 2. Version 1.10 sorting before version 1.9. Invoice 100 at the top of a list that starts at invoice 1.

The reason is that plain alphabetical comparison has no concept of a number. It sees the characters 1 and 0, compares the first one against whatever is in the same position in the other string, and stops as soon as they differ. By the time it reaches the 0 in 10 it has already decided.

Natural collation fixes this by identifying digit runs and comparing their numeric value instead. It costs nothing and it is almost always the ordering a human expects, which is a good argument for reaching for it first whenever your list contains any numbers at all.

When you'd use this

Cleaning up a list before it goes somewhere it will be read — a glossary, an index, a set of options in a dropdown, a bibliography.

Sorting also makes other problems visible. An alphabetically ordered list puts near-duplicates next to each other, so typos, trailing whitespace variants, and accidental repeats become obvious in a way they never are in the original order. That is often a better reason to sort than the ordering itself.

Examples

Why "natural" exists

item10 item2 item1
Alphabetical: item1, item10, item2 Natural: item1, item2, item10

Alphabetical sorting compares character by character, so the "1" in item10 is compared against the "2" in item2 and wins. Natural sorting recognizes the digit run as a number and compares 10 against 2 by value. This is the single most common complaint about sorted lists and the reason files named v1, v2, v10 appear in the wrong order in most file managers.

Uppercase does not really come first

apple Banana cherry
Alphabetical: apple, Banana, cherry Code point: Banana, apple, cherry

In the code point ordering, capital B has a lower numeric value than lowercase a, so Banana jumps to the front. That is what a plain sort in most programming languages does, and it is almost never what a person reading the list wants — which is why alphabetical is the default here.

Frequently asked questions

What is the difference between alphabetical and code point sorting?

Code point sorting compares the underlying numeric value of each character, so all capital letters sort before all lowercase ones and accented letters land far from their unaccented counterparts. Alphabetical sorting uses this site's own collation rules, set to order text the way an English dictionary would. Use code point only when you are deliberately reproducing another system's behavior.

Is the shuffle actually random?

It is deterministic, and that is intentional. The shuffle is seeded from your input, so the same list always produces the same shuffled order. A truly random shuffle would reorder the list on every keystroke while you were still editing, which makes the tool impossible to use. Change any character in the input and you get a different arrangement.

Does it sort non-English text correctly?

For the common case, yes — accented Latin letters land next to their unaccented counterparts, which is right for most languages. What it does not currently do is switch rules by language: correct alphabetical order genuinely differs — in Swedish, å ä ö are separate letters that sort after z, while in German they sort alongside a and o — and this tool applies one fixed rule set rather than detecting which language you are sorting. If a list needs a specific language's collation order, treat the result as a starting point rather than a final answer.

What does the case sensitivity option actually change?

With it off, apple and Apple are treated as the same string for ordering purposes and their relative position is decided by whichever appeared first. With it on, capitalisation becomes part of the comparison and the two are ordered distinctly. It deliberately does not affect accents — é and e stay different either way.

Can it sort numbers properly?

Yes, with Natural selected. A list of bare numbers sorted alphabetically puts 100 before 2; natural sorting compares them by value. This also works for numbers embedded in longer strings, such as invoice references or chapter headings, which is where it is most useful.