Skip to content

Sort Lines Alphabetically

Paste a list with one item per line and sort it alphabetically, in reverse alphabetical order, by line length, or simply flipped upside down. Capital letters and accents do not affect the order, so "apple" and "Éclair" fall where a dictionary would put them. Free, no sign-up, and the text never leaves your browser.

Sort mode

0 lines

How to Use the Line Sorter

  1. Paste your list. One item per line: names, words, keywords, file names, URLs or anything else that sits on its own line.
  2. Choose a sort mode. A to Z, Z to A, by length (short to long or long to short), or Reverse order.
  3. Click Sort. The sorted lines appear under Sorted output, with a count of the input and output lines.
  4. Copy the result. Use Copy Result, or Clear to start again.

The Five Sort Modes

ModeWhat it does
A to ZDictionary order, ignoring capitals and accents
Z to AThe same comparison in the opposite direction
By length, short to longFewest characters first, counting spaces and punctuation
By length, long to shortMost characters first
Reverse orderNot a sort: the last line becomes the first, the first becomes the last

The alphabetical comparison is not case-sensitive, so Apple and apple are treated as equal. When two lines compare as equal, they keep the order they had in your text, so the sort never shuffles ties. Accented letters sort with their base letter, which places Éclair between cherry and File rather than after zebra.

A Worked Example

Here is a nine-line list with mixed capitals, an accent and two numbered items:

Input

banana
Apple
cherry
apple
Banana
Éclair
zebra
File 10
File 2

A to Z

Apple
apple
banana
Banana
cherry
Éclair
File 10
File 2
zebra

By length, short to long

Apple
apple
zebra
banana
cherry
Banana
Éclair
File 2
File 10

Look at the A to Z result. Apple stays above apple because it came first, and banana stays above Banana for the same reason. In the length sort the three five-letter lines come first, then the five six-character lines, and File 10, at seven characters, comes last.

Why "File 10" Comes Before "File 2"

The sort compares text character by character, so File 10 sorts before File 2 because the character 1 comes before 2. It does not read digits as quantities, which is the same trap that catches spreadsheets and file managers. If your lines begin with numbers that matter, pad them with leading zeros (File 02, File 10) or sort the numbers separately with the Number Sorter.

Two more details to know. Blank lines count as lines: they sort to the top in A to Z and to the bottom in Z to A. And a line that starts with spaces sorts before one that does not, because the space is read as a character. Check for stray leading spaces if a line seems to be out of place.

Which Tool Do You Need?

If you want…Use
Plain lines put in A to Z order, by length or reversedThis page
Lines put in random orderShuffle Lines
Numbers sorted by value rather than by characterNumber Sorter
A reference list in alphabetical order, with each entry kept whole and "A", "An", "The" ignoredBibliography Alphabetizer
Library call numbers in shelf orderCall Number Sorter
Repeated lines removedRemove Duplicate Lines

Frequently Asked Questions

How do I sort a list alphabetically online?
Paste the list with one item per line, choose A to Z and click Sort. The lines come back in dictionary order and you can copy them with one click. Choose Z to A for the reverse.
Is the sort case-sensitive?
No. Capitals are ignored, so Apple and apple are equal. When two lines are equal for sorting, they stay in the order you pasted them.
How do I sort lines by length?
Choose By length (short to long) or (long to short). The count includes spaces and punctuation, and lines of the same length stay in their original order.
How do I reverse the order of lines?
Choose Reverse order. The last line becomes the first and so on. It flips the list as it stands and does not sort anything.
Why is 10 sorted before 2?
Lines are compared as text, not as numbers, so the character 1 sorts before 2. Pad numbers with leading zeros, or use the Number Sorter for a list that holds only numbers.
Can it sort my bibliography?
It can sort references that each sit on a single line. For entries that wrap over several lines, or that begin with A, An or The, use the Bibliography Alphabetizer, which keeps each entry together and ignores those articles.
Is my text uploaded?
No. The sorting is done in your browser and the text is not sent or stored.

Related Tools

More in Text Cleanup & Formatting

See all Text Cleanup & Formatting