Sort lines
Alphabetize, length-sort, reverse, shuffle, or numerically sort lines with optional trimming, case-insensitive comparison, and empty-line cleanup.
About the Sort lines
Sort lines reorders a block of lines by whichever rule you pick: alphabetical A to Z or Z to A, by length shortest or longest first, numerically by the first number on each line, a straight reverse of the current order, or a random shuffle. Options let you ignore case, trim surrounding whitespace and drop empty lines before sorting.
It is the tool for tidying a list before you paste it somewhere that cares about order: cleaning import lists, alphabetising names, ranking entries by length, or randomising a set of options for testing or a draw. The output appears beside the input, and you can either apply the sort back onto your working text or copy the result.
How to use it
- Paste your lines into the Input box.
- Pick a sort from the dropdown: alphabetical, by length, numeric, reverse or random shuffle.
- Set the toggles: Case-insensitive (on by default), Trim whitespace and Remove empty lines, to control how lines are compared and cleaned.
- For the shuffle mode, click Re-roll to get a different random order each time.
- Click Apply to rewrite the input with the sorted result, or Copy to copy it without changing the input.
Examples
Alphabetising a name list
Paste a mixed-case list of surnames with Case-insensitive on and choose Alphabetical A to Z. "mcArthur", "Adams", "baker" sort to "Adams", "baker", "mcArthur" by letter, ignoring capitalisation, so the result reads naturally rather than putting all capitals first.
Numeric sort by leading number
Lines like "10. Setup", "2. Intro", "1. Cover" sorted numerically become "1. Cover", "2. Intro", "10. Setup". It reads the leading number on each line, so 10 lands after 2 instead of before it the way a plain text sort would put it.
Shuffling options for a draw
Paste a list of entrants and choose Random shuffle, then press Re-roll until you are happy. Each roll produces a different deterministic order, which is handy for picking a running order or randomising test cases without leaving the page.
Frequently asked questions
- How does numeric sort handle lines without a number?
- It looks for a number at the start of each line, allowing a leading plus or minus and decimals. Lines that have no leading number are treated as the largest value, so they sink to the bottom, and ties fall back to alphabetical order.
- Why does case-insensitive sorting matter?
- A raw sort orders all capital letters before lowercase ones, so 'Zebra' would come before 'apple'. With Case-insensitive on, comparisons ignore capitalisation, giving the human-friendly order most people expect from an A to Z list.
- Is the random shuffle truly random?
- It uses a seeded generator, so a given seed always produces the same order, which keeps results reproducible. Pressing Re-roll picks a new seed from the current time, giving you a fresh arrangement each time you click.
- What is the difference between Reverse and Z to A?
- Z to A sorts the lines alphabetically in descending order. Reverse current order ignores content entirely and simply flips the existing sequence top to bottom, which is useful when your lines are already in a meaningful order you want inverted.
- Does length sort count spaces?
- Yes, length is the full character count of the line, including spaces and punctuation, after any trimming you enabled. When two lines are the same length, the tie is broken alphabetically so the output stays stable.
Good to know
Order of operations matters here. Trimming and empty-line removal happen before the sort, so turning on Trim whitespace can change length-based ordering by stripping leading and trailing spaces, and Remove empty lines prevents blank entries from clustering at the top or bottom. If a sort looks off, check these toggles first, since they quietly reshape the lines being compared.
Alphabetical sorting uses locale-aware comparison, which handles accented characters more sensibly than a raw code-point sort, so names with diacritics interleave roughly where a reader expects rather than being banished to the end. For data that is really numeric, prefer the numeric mode over alphabetical, because alphabetical treats numbers as text and would place '100' before '2'. The shuffle is good for casual randomisation but, being seeded and client-side, is not a cryptographic source of randomness and should not be used where unpredictability must be guaranteed.