twoodo
/

Home/Tools/Text & developer utilities

Sort Lines

Sorts numbers naturally, so item2 comes before item10.

Natural sorting, which is what you want

A plain alphabetical sort compares character by character, so "item10" comes before "item2" — because "1" sorts before "2". Technically correct and almost never what anyone wants.

This uses natural ordering, which recognises runs of digits and compares them as numbers. The sample above demonstrates it: item1, item2, item10 in the order a person would expect.

Case and accents

The sort is case-insensitive and accent-aware, so "Banana" and "banana" sort together and "éclair" sorts with the E words rather than at the end. This uses the browser's own collation, which follows the conventions of your locale — and those genuinely differ between languages. In Swedish, ä sorts after z; in German it sorts with a.

The shuffle is properly random

It uses a Fisher-Yates shuffle driven by the browser's cryptographic random source. The naive approach of sorting by a random comparator produces a noticeably biased result, and it is a common bug in code that draws names or picks winners.

Common uses

  • Alphabetising a list of names, tags or references.
  • Sorting file names that contain numbers.
  • Shuffling a list to draw an order fairly.
  • Finding the longest or shortest entries by sorting on length.

Questions people ask

Why does item10 come before item2 in other tools?

Because a plain sort compares character by character and '1' sorts before '2'. Natural ordering compares runs of digits as numbers.

Is the sort case-sensitive?

No. 'Banana' and 'banana' sort together, and accented letters sort with their base letter according to your locale.

Is the shuffle genuinely random?

Yes. It uses a Fisher-Yates shuffle with the browser's cryptographic random source. Sorting by a random comparator, the common shortcut, produces a biased result.

Does sorting change my original text?

No. The result appears separately, and nothing is saved or sent.

Your text stays in the page

This matters more here than on most tools. People paste API keys into hash generators, customer data into CSV converters, contract wording into diff checkers and configuration into JSON validators. Almost every site offering these sends your input to a server to process it.

Nothing here is transmitted. The work happens in your browser, this site is static files with no server behind it, and the about page lists every request the site makes, read live from your own browser so you can check rather than trust.