How to sort lines alphabetically
- 1 Paste your list into the Your text box, one item per line.
- 2 Choose how to sort: A to Z, Z to A, numbers, length, reverse or random.
- 3 Tick the extra options you need, such as Remove duplicates.
- 4 Copy or download the sorted list.
Natural order and capital letters
Simple sorting compares text one character at a time, which gives surprising results:
- Numbers: item10 comes before item2, because 1 is smaller than 2. Natural order reads the number as a whole and puts item2 first.
- Capitals: sorting by character code puts every capital before every lower-case letter, so Zebra lands before apple. This tool sorts like a dictionary instead, and case-insensitive mode treats Apple and apple as equal.
- Accents: letters like é are sorted next to e, the way a dictionary does it.
Sorting also brings duplicates next to each other; remove them with Remove Duplicate Lines. Then number the result with Add Line Numbers.
Features
Seven sort orders
Alphabetical both ways, by number, by length, reversed or shuffled.
Natural order
Item 2 comes before Item 10, as people expect.
Case-insensitive
Sort apple and Apple together.
Clean as you sort
Remove duplicates and empty lines in the same step.
When to use it
Name lists
Alphabetise students, guests or customers. Remove Duplicate Lines from the sorted list.
Glossaries
Order terms for a document or website. Number the result with Add Line Numbers.
Code
Sort imports, keys or config lines. Compare two lists with the Diff Checker.
Random draws
Shuffle names for a fair random order. Make capitals consistent with the Case Converter.
Related Text tasks
Frequently asked questions
What is natural order?
Natural order reads numbers inside text as numbers, so File 2 comes before File 10. Without it, File 10 would come first because 1 is less than 2.
How does Sort by number work?
It finds the first number in each line and sorts by its value, so 2 bananas comes before 10 bananas.
Is the random shuffle truly random?
It uses a fair shuffle, so every order is equally likely. Each change of setting shuffles again.
Does it work with other languages?
Yes. Sorting follows the rules for letters with accents and other alphabets.
How do I sort a list in reverse alphabetical order?
Choose Z to A. The same natural order and case options apply, so numbers and capitals are still handled sensibly.
Can I sort names by surname?
Not directly, because the tool sorts by the start of each line. Put the surname first, for example Khan, Ali, and then sort.
How does sorting by length work?
Lines are ordered by how many characters they contain, shortest first or longest first. It is useful for finding very short or very long entries in a list.
Can I sort numbers correctly?
Choose Numbers (smallest first) to sort by the value in each line, so 9 comes before 10 and 100. Alphabetical sorting would put 10 first.
Can I shuffle a list randomly?
Yes. Random shuffle puts the lines in a new random order each time you press it, which is useful for draws, quizzes and picking turns.
How this tool works. These text tools run entirely in your browser with plain JavaScript, so the text you paste never leaves your device and results update as you type. Each tool is tested with real text such as copied PDFs, emails, code, lists, emojis and non-English scripts before it goes live.
Built and reviewed by Hamza Farooq, founder and lead developer
· Last updated
· How we check our tools
· Report a problem