Sort Lines Alphabetically
Sort the lines of a list alphabetically, by number, by length, or in natural order such as file2 before file10.
Line sorter
One item per line. Choose how to sort.
Result
Sorted lines
10 9 Apple banana cherry pear
6
Lines
Private: Everything runs in this page. Nothing you type is sent anywhere or saved.
On this page
Sorting examples
| Lines | Sorted by | Result |
|---|---|---|
| pear, Apple, fig | az | Apple | fig | pear |
| pear, Apple, fig | za | pear | fig | Apple |
| file10, file2, file1 | natural | file1 | file2 | file10 |
| 10, 9, 100 | num | 9 | 10 | 100 |
| ccc, a, bb | length | a | bb | ccc |
Formula
A to Z compares the lines letter by letter
How the line sorter works
- Step onePaste your list with one item on each line.
- Step twoChoose the sort order. Natural order treats the number inside a name as a number.
- Step threeCopy the sorted list from the box.
What this tool does not do
- Alphabetical order here follows character codes, not the rules of a language, so accented letters sort after plain ones.
- Number sort reads the number at the start of a line only.
- It does not remove duplicate lines; use the duplicate remover for that.
Frequently asked questions
Why does plain A to Z put file10 before file2?
Letter-by-letter order compares the character 1 with 2 first. Choose natural order to sort the numbers inside names the way people expect.
What happens to lines that are not numbers in number sort?
They are placed at the end, in their original order.
Is the sort stable?
Yes. Lines that compare as equal keep the order they had.