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
appleprecedesApple, which precedesbanana. - Accents are secondary:
élansorts 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 10andChapter 11come beforeChapter 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.