Skip to content
Dev Utilities

Text sorter

Sort, reverse, shuffle and dedupe lines

Options

Alphabetical order is a property of the language, not of the characters. Switch between German and Swedish with the sample loaded to see it.

Comparison and filtering
0 chars
0 chars

Why the ordering is not a plain comparison

  • "Z" < "a" is true in JavaScript, because < compares UTF-16 code units and ASCII puts every capital before every lowercase letter. A plain sort() therefore gives Apple, Zebra, apple. This tool uses Intl.Collator, which implements the Unicode Collation Algorithm.
  • Accented letters are worse: "ä" is U+00E4, far above "z", so code-unit order banishes it to the end. Collator places it where the chosen language says it goes.
  • Shuffle is a Fisher–Yates pass over crypto.getRandomValues with rejection sampling, so every ordering is equally likely. The common sort(() => Math.random() - 0.5) trick is not a shuffle: a comparator that answers differently for the same pair breaks the sort's contract, and the result is biased by whichever algorithm the engine uses.
  • By length counts code points, so an emoji counts as one character. Ties fall back to the collator so the result is stable and readable.