EthicalFusion

Text Sorter A-Z

Sort lines alphabetically from A to Z.

Was this tool helpful?

Thanks for the feedback!

Text Sorter A-Z puts the lines of your text into alphabetical order, one item per line. It uses your browser's language-aware comparison rather than raw character codes, so "apple" and "Apple" sit together and "élan" files under E, the way a person would expect a name list or glossary to be ordered.

How the alphabetical comparison works

  • Case is secondary: words are grouped regardless of capitals. When two lines differ only in case, the lowercase one comes first, so apple precedes Apple, which precedes banana.
  • Accents are secondary: élan sorts among the E words, not after Z as it would in a plain code-point sort.
  • Spaces and punctuation come first: a line starting with a space, underscore or # appears above all lines that start with a digit or letter.
  • Digits are compared one character at a time: Chapter 10 and Chapter 11 come before Chapter 2, because "1" is smaller than "2".
  • Other scripts follow Latin: Hindi lines are placed after English ones, in the order of the Devanagari alphabet (अ before क before न).

The exact rules come from your browser's language settings, so a handful of accented letters can land slightly differently on a device set to, say, Swedish or German.

Example: a class list

Sharma, Neha
Iyer, Arjun
khan, Imran
Agarwal, Riya
Iyer, Anil

becomes

Agarwal, Riya
Iyer, Anil
Iyer, Arjun
khan, Imran
Sharma, Neha

Writing names as "Surname, First name" sorts by surname, which is how most school rolls and attendance registers are arranged. Notice that the lowercase "khan" is still placed correctly between I and S.

What the sorter keeps and drops

  • Completely empty lines are removed. Lines containing only spaces are kept and float to the top.
  • Duplicate lines are kept and end up next to each other, which makes them easy to spot. Pass the sorted list to the Duplicate Line Remover to drop repeats.
  • The text inside each line is never changed, including its capitals and punctuation.

Fixing number order and other tips

To make numbered items sort correctly, pad the numbers with leading zeros: Chapter 02, Chapter 10, Chapter 11. The same trick works for invoice numbers, roll numbers and file names. Remove leading spaces first (the extra space remover trims them) so indented lines do not jump to the top.

Common jobs for an A-Z sort include glossaries and index terms, product and ingredient lists, keyword lists, and reference lists. It also sorts a reference list: paste one citation per line, and because APA, MLA and Harvard all order entries by the first author's surname, an A to Z sort puts them in the right order as long as each line starts with that surname. For reverse alphabetical order, use the Z-A version of this sorter.

Frequently asked questions

Why does 10 come before 2 in my sorted list?
Numbers inside text are compared digit by digit, and 1 is smaller than 2. Add leading zeros, such as 02 and 10, to get numeric order.
Is the sort case-sensitive?
Not in the usual sense. Words are grouped alphabetically regardless of capitals, and when two lines differ only in case the lowercase one comes first.
Where do Hindi words go in the sorted list?
Lines written in Devanagari are placed after English lines and are ordered according to the Hindi alphabet.
Does sorting remove duplicate lines?
No. Duplicates are kept and end up next to each other, so they are easy to find and remove.
Why is a line at the very top even though it starts with Z?
It probably starts with a space or a symbol, which sort before letters. Trim leading spaces before sorting.

Related tools

Embed this tool on your site

Paste it into any blog or website. Free, with a credit link.