Sort Lines Alphabetically

Put any list in order: alphabetical, reverse, natural number order, by length, or shuffled.

2 lines sorted

Last reviewed:

Alphabetical order vs computer order

Many programs sort by the numeric codes behind each character. In that order every capital letter comes before every lowercase one, so “Zebra” lands ahead of “apple”, and accented letters drift to the very end. This tool sorts the way a dictionary or phone book would, keeping Apple and apple together and filing éclair under e.

Character-code orderA to Z here
AppleApple
Bananaapple
ZebraBanana
appleéclair
éclairZebra

With Case sensitive off, Apple and apple are treated as equal and keep the order they came in. Turn it on and, in most languages' rules, lowercase sorts just before uppercase for otherwise identical words.

Natural sort for numbered items

Plain alphabetical order compares text one character at a time, so “file10” comes before “file2” because 1 is smaller than 2. Natural order reads whole numbers as numbers. It's the setting you want for chapters, invoice numbers, room numbers and software versions.

A to ZNatural (2 before 10)
file1file1
file10file2
file2file10
Room 10Room 9
Room 9Room 10
1.101.2
1.21.9
1.91.10

If the list will be sorted again in a program without natural order, pad numbers with leading zeros (file01, file02, file10). Then plain A to Z gets it right everywhere.

Natural order also understands negative numbers and decimals. A list of 1.5, 1.25, 10, 2, -3 and -10 comes out as -10, -3, 1.25, 1.5, 2, 10, which is the order you'd expect on a number line. A minus sign only counts as negative at the start of a line or after a space, so a code like A-3 still sorts as text. For tables with several columns of numbers, a spreadsheet gives you more control over which column decides the order.

Accents and other alphabets

Alphabetical order isn't the same in every language, and the sort follows the language your browser is set to. In English rules, ñ is just an n with a mark, so it files among the n words. In Spanish, ñ is its own letter after n. Swedish puts å, ä and ö after z.

Browser languageSorted result
Englishllama, luna, ñandú, nube, oso, zorro
Spanishllama, luna, nube, ñandú, oso, zorro
EnglishÅl, Apa, Ödla, Zebra
SwedishApa, Zebra, Ål, Ödla

If a list is for readers of one language, such as a Spanish class roster or a Swedish recipe index, sorting on a device set to that language gives the order they expect. For mixed lists, any consistent order works; just know that two people whose browsers use different languages may see a few names land in slightly different places.

Sorting dates and names correctly

Sorting works on the text itself, so dates sort correctly only if the biggest unit comes first. US-style month/day/year dates sort by month, mixing up years. The international ISO 8601 format, year-month-day, sorts into true date order every time.

Example: Three deadlines sorted A to Z

  1. US style: 03/15/2026, 07/04/2025, 12/01/2025 (wrong: 2026 comes first)
  2. ISO style: 2025-07-04, 2025-12-01, 2026-03-15 (right)

Write dates as YYYY-MM-DD in any list you plan to sort, including file names.

Names sort by their first character, so “Maria Santos” files under M. To sort a class list by surname, flip each line to “Santos, Maria” first. Find and Replace can do that for a whole list in one go with a regular expression.

Shortest first, reverse and random

Sorting by length puts the shortest lines first (or last), with ties in alphabetical order: fig, kiwi, pear, apple, banana. It's handy for finding the longest product name before you design a label, or spotting cut-off entries in an export.

Reverse current order flips the list without sorting it. Use it to turn a newest-first log or chat export into oldest-first. Random order shuffles the lines using your browser's cryptographic random number generator, so every arrangement is equally likely. For classroom draws, the Name Picker adds a bit of ceremony.

Tidy the list before you sort

Stray characters at the start of a line decide where it lands. A line with a leading space sorts before everything else, and bullet points or dashes sort before letters. In a test list, “ Zoe” (with a leading space) came first and “- Beth” came before “Adam”.

Sorting also exposes hidden repeats, because identical lines land next to each other. A quick scroll down a sorted list shows doubled entries you might never spot in the original order.

Sorting a grocery list by aisle? Prefix each item with the aisle number (04 Bread, 07 Milk) and sort naturally. Delete the prefixes afterward if you like.

Sources and further reading

How to use it

  1. 1Paste your list.
  2. 2Pick a sort order.
  3. 3Copy the sorted list.

Questions

What is natural sort?

Numbers inside text are compared as numbers, so 'Item 2' comes before 'Item 10'.

Is my text uploaded anywhere?

No. Everything happens in your browser; your text never leaves your device.

Also handy: Shuffle a List, Text to QR Code