Skip to content
Sort Lines

Sort Lines

Sort lines alphabetically, numerically, or by length. Shuffle and reverse them too.

This sorter takes a list (one item per line) and reorders it instantly in your browser. Five modes cover the common cases: smart alphabetical, numeric, by line length, random shuffle, and a simple reverse. Nothing is uploaded; the whole tool runs client-side, so it is safe for log excerpts, customer lists, or anything else you would rather not paste into a random server-backed site.

How to use

  1. Type or paste one item per line into the input on the left. The Paste, Sample, and Clear buttons above the input speed up edits.
  2. Pick a sort mode: Alphabetical, Numeric, By length, Shuffle, or Reverse order. Tick Reverse to flip a sorted result, or Skip empty lines to drop blanks. In Shuffle mode, press Reshuffle to draw a new random order.
  3. Copy the live result from the right-hand pane or download it as a .txt file. Both panes show a running line count.

Natural sort: why item2 comes before item10

A plain character-by-character sort puts item10 before item2, because the character 1 ranks before 2. The Alphabetical mode here uses natural ordering instead, comparing embedded digit runs as whole numbers. Given this input:

item10
item2
item1

the sorted output is:

item1
item2
item10

That is almost always what you want for filenames, versions, IDs, and chapter lists. The comparison is also case-insensitive, so Apple and apple sort together rather than splitting into an uppercase block and a lowercase block.

Numeric vs. alphabetical on mixed data

Numeric mode parses each line as a number (it reads the leading number, so 3 apples sorts as 3). Lines that do not start with a number, such as banana or $5, sink to the bottom, alphabetised among themselves. Use Numeric for price lists, scores, and measurements; use Alphabetical when lines are mostly text that happens to contain digits.

Shuffle and reverse

Shuffle uses a Fisher-Yates shuffle for an unbiased random order, which makes it handy for raffles and prize draws, picking a random sample from a list, randomising quiz questions, or breaking an order-related bias before review. Hit Reshuffle until you like the draw. Reverse order simply flips the list end to end, no sorting involved. That is useful for turning a newest-first log into oldest-first.

FAQ

More questions? Browse the full FAQ.

After sorting, you can remove duplicate lines from the sorted list (duplicates end up adjacent, which makes them easy to spot) or run a find & replace to clean up prefixes or separators before pasting the list back into your document.

Search tools

Search all Textbench tools