Text Sorter

Sort any list of lines into order. Natural sorting puts item2 before item10 the way a person would, and you can reverse the direction, sort by length, shuffle randomly, or strip duplicates in the same pass.

Your files never leave this device

Sort your lines Live · Natural number ordering

Sort by

Natural handles embedded numbers sensibly. Strict A. Z compares character by character.

Direction
Also

How to sort a list

  1. Paste your list into the box above, one item per line.
  2. Choose how to sort, natural order handles most lists correctly.
  3. Pick ascending or descending, and decide whether capitalisation should matter.
  4. Tick Remove duplicates if the list should also be deduplicated.
  5. Copy the sorted result, or download it as a text file.

What this sorter offers

  • Natural ordering, so file2 comes before file10 rather than after it.
  • Strict alphabetical comparison when you need exact character order.
  • Sorting by line length, shortest or longest first.
  • A genuine random shuffle for drawing names or randomising test data.
  • Optional deduplication, trimming and blank-line removal in the same pass.
  • Locale-aware comparison, which handles accented characters correctly.

Why sorting is not as simple as it looks

Ask most software to sort a list and it compares strings character by character using their underlying numeric codes. That works for plain words and produces obviously wrong results as soon as numbers are involved. Strict comparison puts item10 before item2, because the character "1" comes before "2". The fact that ten is larger than two never enters into it.

Natural sorting is the fix. It recognises runs of digits inside a string and compares them as numbers, so a list of files, chapters, versions or invoice references comes out in the order a person would put it. That is the default here, because it is what people almost always mean.

The four modes

  • Natural: the sensible default. Handles embedded numbers as numbers.
  • Strict A. Z: exact character comparison, for when you need to match another system's ordering precisely.
  • Length: shortest to longest, useful for finding outliers and for arranging keyword lists.
  • Random: a proper Fisher. Yates shuffle, not a sort with a random comparator, which is subtly biased.

Case and accents

By default capitalisation is ignored, so "apple" and "Apple" sit together rather than in separate blocks. That is almost always what you want for a human-readable list. Turn it off when you need capital letters grouped separately, which is the convention in some programming contexts.

Comparison uses your browser's locale rules rather than raw character codes, which means accented letters sort next to their base letters, "éclair" lands near "eclair" rather than after "z", where a naive byte comparison would put it. That matters for any list containing names.

Why random is done properly

A common trick for shuffling is to sort with a comparator that returns a random value. It looks right and is measurably biased: some orderings come up far more often than others, because sorting algorithms assume a consistent comparator and this one is not.

This tool uses the Fisher. Yates shuffle, which produces every possible ordering with equal probability. If you are drawing names, allocating participants to groups or randomising test data, that difference is worth having. Note that it uses the browser's standard random number generator, which is fine for these purposes but is not cryptographically secure, for anything where fairness must be provable, use a dedicated method.

Sorting alongside the other cleanups

Trimming and blank-line removal are on by default because unsorted list data almost always contains both, and an untrimmed line sorts by its leading space rather than its content. Deduplication is off by default, since removing entries is destructive, turn it on deliberately.

For deduplication with more control over which copy survives, the duplicate line remover is the better tool. To check what you ended up with, the line counter reports the totals. Everything runs in your browser and nothing is uploaded.

Frequently asked questions

Why does item10 sort before item2 in other tools?

Because they compare character by character, and the character 1 comes before 2. Natural sorting recognises runs of digits and compares them as numbers, which is the default here.

Does sorting handle accented characters correctly?

Yes. Comparison uses your browser's locale rules, so éclair sorts next to eclair rather than after z, which is where a raw byte comparison would place it.

Is the random shuffle actually fair?

Yes. It uses a Fisher. Yates shuffle, which gives every ordering equal probability. Sorting with a random comparator, the common shortcut, is measurably biased.

Can I sort and remove duplicates at the same time?

Yes. Tick Remove duplicates and both happen in one pass. Deduplication is off by default because removing entries is destructive.

Why are trimming and blank-line removal on by default?

Because unsorted list data almost always contains both, and an untrimmed line sorts by its leading space rather than its content, which produces confusing results.