Skip to content

Text Tools

Sort lines of text

Alphabetical, natural, by length, or random. Ascending or descending.

  • Free, no signup
  • No upload — runs on your device
  • No watermark
  • Unlimited use

Sort Lines

Processed locally

Alphabetical sorting puts file10 before file2

A plain alphabetical sort compares strings character by character, so file10 sorts before file2 because 1 precedes 2. This is correct string ordering and completely wrong for anything a human numbered. Version numbers, chapter headings, invoice references and photo filenames all suffer from it.

Natural sort recognises runs of digits and compares them as numbers, so file2 precedes file10. It is what file managers do, what people expect, and what plain sorting never gives you. This tool uses the browser's own Intl.Collator with numeric collation, which also handles accented characters correctly — é sorts next to e, not after z.

The one place plain alphabetical wins is when the output feeds a system that will do a string comparison itself. Match the sort to what happens downstream, not to what reads nicely.

How it works

  1. Paste your list
  2. Choose a sort mode and direction
  3. Copy the sorted result
Why nothing uploads. Every operation on this page happens inside your browser using JavaScript and WebAssembly. Your file is read into memory, processed, and offered back as a download. It is never transmitted. Disconnect from the internet after this page loads and the tool keeps working.

Frequently asked questions

Why does file10 sort before file2 alphabetically?
Because string comparison looks at characters left to right, and "1" comes before "2". Choose natural order and the digits are compared as numbers, putting file2 first.
When should I use natural sort?
Whenever the lines contain numbers a human wrote — version strings, chapter numbers, invoice references, photo filenames. It is almost always what you meant.
Does sorting handle accented characters correctly?
Yes. The browser's collator places "é" next to "e" rather than after "z", which is what every language's dictionary does.
What does sorting by length do with ties?
Lines of equal length fall back to alphabetical order, so the result is stable and repeatable rather than arbitrary.
Can I shuffle instead of sorting?
Yes — choose random. It uses a Fisher-Yates shuffle, which is uniformly random, unlike the sort-with-random-comparator trick that biases the result.