Sort Lines Alphabetically

Paste a list and get its lines back in A-to-Z order.

FluffyShield Protected workspace
FluffyShield

Isolated workspace: other page scripts can't read your files. How FluffyShield works

Free · No upload · No sign-up · No usage quotas

Why does photo-2.jpg come before photo-10.jpg?

Because the digits in a line are compared as a number: 2 is smaller than 10, so photo-2.jpg comes first even though its line is shorter.

How two lines are compared
  1. Split the line into text and runs of digits
  2. Compare the text with the browser's collation
  3. Compare each run of digits by its value

What it does

Capitals with their twins

Apple sits next to apple. Capitals aren't sent to the top as a group.

Your browser's language

In English, Äpfel files under A. A browser set to Swedish puts it after Zucker, because Ä is one of the letters after Z in the Swedish alphabet.

Repeats stay

A line that's in the list twice is sorted twice. Remove Duplicate Lines takes the second one out.

Limits A blank line sorts to the very top.

Six photos numbered between 1 and 20, in a strange order

Suppose you're sending someone six photos, numbered between 1 and 20 and named from photo-1.jpg up to photo-20, and you want to list them in order in your message. You paste the names here, and the list starts photo-1.jpg, photo-2.jpg, photo-3.jpg. photo-10.jpg turns up in fourth place.

That's the order you'd count in. The tool reads a run of digits as one number, so 10 comes after 9 and before 11, and every line comes back exactly as you typed it.

Numbers as typedTwo digits eachphoto-1.jpgphoto-2.jpgphoto-3.jpgphoto-10.jpgphoto-11.jpgphoto-20.jpgphoto-01.jpgphoto-02.jpgphoto-03.jpgphoto-10.jpgphoto-11.jpgphoto-20.jpg

Sorted twice

Both lists run in the order of the numbers in the names. Zero padding changes the spelling but not the order. How we checked

Reading the numbers as numbers

A plain text sort looks at one character at a time, so it puts 10 before 2: the 1 is smaller than the 2, and the 0 never gets a say. This tool reads each run of digits as a whole number and compares the numbers instead.

That is why photo-2.jpg comes before photo-10.jpg. The letters around the digits still follow your browser's alphabet order, so your language setting can move a few letters but never the numbers.

You don't need to pad numbers with zeros. photo-01.jpg and photo-1.jpg sort to the same place, and the tool keeps whichever spelling you pasted.

Putting your own list in order

Paste your names as they are. Numbers in a line are compared by value, so 2 comes before 10.

  1. Paste the names into the Lines box, one to a line.

  2. Read down the Sorted A → Z box for a 10 sitting above a 2. A wide screen shows the box beside your list; a phone keeps it under Result.

    The top of the Sorted A to Z box: photo-1, then photo-10 and photo-11, then photo-2.
    The top of the Sorted A to Z box: photo-1, then photo-10 and photo-11, then photo-2.
  3. If you find one, put a 0 in front of each single digit in the Lines box. The sorted list changes as you type.

Other orders

You want Z to A, or the list turned upside down

Text cleaner

Sorted Z → A and Reversed lines are two more choices under To there. Reversed lines keeps your order and flips it.

Search FluffyBench