Text & Writing
Sort Lines (Alphabetical, Numeric, Random)
Sort a list alphabetically, numerically, by length or randomly — ascending or descending, with natural number ordering.
How to use
- 1Paste a list with one item per line.
- 2Pick a sort method and order, then copy the sorted list.
Frequently asked questions
What is natural sorting?
Numbers inside text are compared as numbers, so 'file2' comes before 'file10' instead of after it.
How are lines without numbers handled in numeric sort?
They are placed after all lines that start with a number, in their original order.
Is the random shuffle fair?
Yes. It uses a Fisher-Yates shuffle with your browser's secure random generator, so every order is equally likely.
A worked example of natural sort vs plain alphabetical
file10, file2, File1 sorted alphabetically (natural, the default) comes back as File1, file2, file10 — in true plain-string alphabetical order, "file10" would sort before "file2" because the character "1" comes before "2", regardless of what follows. Natural sorting instead recognizes the embedded number and compares it numerically, so 2 correctly sorts before 10. This is exactly the behavior you want for sorting filenames, version numbers, or any list where numbers are embedded in otherwise-alphabetic text — plain alphabetical sort would scatter file2, file10, file20 and file3 in a confusing order that doesn't match how a human would expect a numbered list to read.
Why non-numeric lines sort to the end in Numeric mode, not the error-prone middle
Sorting 10, -2, 3.5, abc, 1,000 by Numeric value produces -2, 3.5, 10, 1,000, abc — note "1,000" is correctly parsed as one thousand (the comma is stripped before parsing) and placed by its numeric value, while "abc" (which has no leading number at all) is pushed to the very end rather than being sorted arbitrarily or crashing the sort. This is a deliberate rule: a line with no parseable number has no numeric value to compare, so rather than guessing or erroring out, the sort treats "not a number" as "after every number," which keeps the sort stable and predictable even on a messy, mixed list.
Why the random shuffle specifically avoids Math.random()
The shuffle uses crypto.getRandomValues (the Web Crypto API's cryptographically secure random number source) rather than the more commonly used Math.random(), specifically so the Fisher-Yates algorithm produces a genuinely uniform shuffle — Math.random() is a fine source of randomness for most purposes but isn't guaranteed to be free of subtle statistical bias across implementations, which matters if you're using this for something like a raffle draw or picking a random team order where perceived fairness is part of the point. Fisher-Yates itself is the right algorithm choice too: a naive "sort by random comparator" shuffle (common in quick one-liner implementations) is mathematically provable to produce biased, non-uniform orderings, while Fisher-Yates guarantees every permutation is equally likely.
Descending still leaves numberless lines at the bottom
Descending is hidden when I pick Random shuffle or Reverse current order, because those have no direction. On Numeric value, turning Descending on reverses only the lines that parsed as numbers. A line like abc stays at the bottom either way. I checked with 10, then -2, then abc, then 3: descending comes out 10, 3, -2, abc, not with abc first. A thousands separator is stripped, so 1,000 sorts as one thousand. Length sort uses the character count, and when two lines are the same length it falls back to alphabetical order. Empty lines are removed unless I turn that off. Alphabetical comparison ignores case, so File and file are ties apart from the numbers inside them.
Related tools
- Bullet & Line Formatter
Add bullets, numbers, a prefix or a suffix to every line of a list — or strip existing bullets and numbering.
- Remove Line Breaks
Join broken lines into flowing text — fix copy-pasted PDF and email text while keeping paragraph breaks if you want.
- Remove Duplicate Lines
Delete repeated lines from a list and keep the first occurrence of each, with options to ignore case and blank lines.
- Sentence & Paragraph Counter
Count sentences and paragraphs and see average sentence length — a quick structure check for essays and articles.
- Fantasy Draft Order Randomizer
Randomize a fair fantasy football, basketball or baseball draft order — with snake-draft round order shown.
- Text to Speech (Read Aloud)
Have any text read aloud with natural voices — choose the voice, language, speed and pitch. Free, private and runs in your browser.