Guide

How to Sort Lines Alphabetically, Numerically and by Length

Understand the different ways to sort a list of lines and how to choose the right mode for names, numbers and data.

A sort-lines tool reorders the lines of a text block according to a rule you choose — alphabetical, numerical, by length, or reverse. It turns a random list into something you can scan, compare, and import.

Sorting modes explained

  • Alphabetical A→Z — dictionary order, case-insensitive by default.
  • Alphabetical Z→A — reverse dictionary order.
  • Numerical — sorts by the leading number on each line (10 comes after 9, not after 1).
  • By length — shortest to longest, or vice versa.
  • Random / shuffle — reorders lines with no pattern.
  • Reverse — flips the current order without sorting.

Choosing the right mode

Use alphabetical for names, titles, and words. Use numerical only when each line begins with a number — alphabetical sort would put "10" before "2" because it compares character by character. Use length sort when you want short entries first (e.g. two-letter words) or longest first (e.g. highest-scoring plays).

How to sort a list

  1. Paste your list, one item per line.
  2. Pick the sort mode that matches your data.
  3. Optionally remove blank lines and deduplicate in the same pass.
  4. Copy the sorted result.

Examples

Lines "10 apples", "2 bananas", "1 cherry" sort alphabetically as "1 cherry", "10 apples", "2 bananas" — clearly wrong for numbers. Switch to numerical sort and you get "1 cherry", "2 bananas", "10 apples" — the intended order.

When sorting lines is useful

  • Alphabetising name lists, glossaries, and bibliographies.
  • Ordering numbered items or ranked data.
  • Grouping words by length for word games.
  • Preparing sorted data for import or display.

Put it into practice

Use the Sort Lines right now — free, in your browser, no sign-up required.

Try the Sort Lines