Sort Lines Alphabetically

Sort lines A to Z, Z to A, by length, naturally or by number.

Result

Apple
banana
item1
item10
item2
item20
item3
7 lines · 44 bytes
  • 7 lines sorted.

How does sorting lines work?

Sorting puts lines in order. The usual choice is alphabetical, A to Z or Z to A. But plain alphabetical order treats numbers as text, so "item10" comes before "item2" because the character 1 is less than 2. That is rarely what a person wants.

This tool offers several modes. Natural sort reads the digits as whole numbers, so item2 comes before item10. "By the first number" sorts by the number found in each line. "By length" orders by character count. You can also choose whether capital letters count. Sorting is stable, so equal lines keep their original order.

How to use the Sort Lines Alphabetically

  1. Paste your lines, one item per line.
  2. Choose a sort mode.
  3. Decide whether letter case should matter.
  4. Copy the sorted list.

Real situations

When people use the Sort Lines Alphabetically

  • 1

    Tidy a list of names or words

    Put a pasted list in alphabetical order before sharing it or adding it to a document.

  • 2

    Sort file names with numbers

    Natural sort puts file1, file2, file10 in the order people expect rather than file1, file10, file2.

  • 3

    Order code lines

    Sort import statements, CSS properties or config keys so changes are easier to compare.

  • 4

    Find the longest or shortest lines

    Sort by length to bring the very long entries or the very short ones to the top so you can inspect them.

FAQ

Sort Lines Alphabetically: questions answered

What is natural sort?

Natural sort compares the numbers inside text by value instead of character by character. With it, item1, item2, item3, item10, item20 appear in that order. With plain A to Z they come out as item1, item10, item2, item20, item3.

Why do capital letters come first?

With "Match case", all capital letters sort before lowercase ones, so Zebra comes before apple. Choose "Ignore case" to sort without regard to capitals, so Apple, banana and cherry are in alphabetical order whatever their capitalization.

How does "By the first number" work?

It looks for the first number on each line and sorts by it. In the sample, item1, item2, item3, item10, item20 come out in numeric order, and lines with no number, such as Apple and banana, go to the end.

Can it sort Z to A?

Yes. Choose "Z to A" for reverse alphabetical order. To simply flip a list upside down without sorting, use the reverse lines tool.

Does it remove duplicates?

No. Duplicate lines stay in the output. Use the remove duplicate lines tool first or afterwards if you want a unique, sorted list.

Is sorting stable?

Yes. Lines that compare equal stay in the same order as in your input, which matters when you ignore case or sort by length.

Is this Sort Lines Alphabetically free and private?

Yes. It is free with no sign-in, and every calculation runs inside your browser. Nothing you type is sent to a server or stored, and the page keeps working offline once it has loaded.

Private by design. No accounts, no cookies, no tracking. Everything you type stays on your device.

How we keep it that way