Sort Lines Alphabetically, Naturally, by Number or by Length
Paste a list and sort the lines A to Z, by natural number order, by the number at the start, or by length. Remove repeats and blank lines, then copy the result. Runs in your browser.
Your text stays in this browser. Nothing is uploaded or sent to a server, and it is not put in the page address.
The tool failed to load. Please reload the page.
Report a problem
Nothing is sent until you press Send.
When to use this
- You have a list of names, files, tags or words and want it in order.
- Your lines include numbers and plain A to Z puts item 10 before item 2.
- You also want repeats and blank lines taken out in one step.
How to use
- Paste your lines, one item per line.
- Pick how to sort. Natural order treats the numbers inside a line as numbers.
- Tick the descending, ignore case, remove repeats, remove blank lines and trim options if you need them.
- Press Sort lines, then copy the result or download it as a text file.
Examples
- Natural order: item 10, item 2, item 1 sorted naturally gives item 1, item 2, item 10. A to Z gives item 1, item 10, item 2.
- Number at the start: 30 apples, 4 pears, 200 plums sorted by the number at the start gives 4 pears, 30 apples, 200 plums.
Understanding the result
Alphabetical compares letters one by one using English order, with upper and lower case treated alike unless you turn that off. Natural order also reads runs of digits as whole numbers. Number at the start uses the first number on each line, and lines with no number go to the end. Length counts characters. In an A to Z sort, lines that tie keep their original order. In length and number sorts, ties are put in alphabetical order.
Assumptions this tool makes
- One item per line.
- Letters are ordered by English rules. Accented letters sort next to their plain letter.
- Repeated lines match when the whole line is the same, ignoring case if that option is on.
Limitations
- Other languages may expect a different order, for example letters that English does not use. Check the result if you sort non-English text.
- The number at the start must be a plain number such as 12 or 3.5. Dates and fractions are not read as numbers, and a thousands separator stops the number, so 1,200 is read as 1.
- Text is limited to 100,000 lines and 1,000,000 characters.
- Very long lists may be slow on an old phone.
FAQ
Why does item 10 come before item 2?
Plain alphabetical order compares one character at a time, and 1 comes before 2. Choose Natural order to sort the numbers by value.
Can I remove repeated lines at the same time?
Yes. Tick Remove repeated lines. The first copy of each line is kept, and the page says how many were removed.
What does Reverse the current order do?
It flips your list upside down without sorting it, so the last line becomes the first.