Sort lines
Paste a list and sort it alphabetically, numerically, by length, at random or in reverse, with optional removal of duplicate and empty lines. Free, and your text stays in your browser.
How to use it
- Paste your list in Your lines, one item per line.
- Pick the order in Sort order.
- Tick Remove duplicate lines or Remove empty lines if you want a cleaner list.
- Copy the result from Sorted lines.
Complete guide to sorting lines of text
When sorting lines helps
A list in the wrong order is hard to use. Names pasted from a chat, a column copied from a spreadsheet, a list of keywords, domain names, file names, tags or product codes: put them in order and duplicates sit next to each other, gaps become obvious and anything is quick to find. Spreadsheets can sort, but opening one for a ten-line list is overkill. This tool sorts any text, one item per line, in eight ways, and can clean the list at the same time.
The eight sort orders
| Order | How it works |
|---|---|
| A to Z and Z to A | Alphabetical, using your language rules, so accented letters fall where a dictionary puts them |
| Numeric, smallest first and largest first | Reads the first number found in each line, including decimals and negatives. A comma or a point works as the decimal mark. Lines without a number go last |
| By length, shortest first and longest first | Counts the characters in each line. Lines of equal length keep their original relative order |
| Random (shuffle) | A new random order every time. Useful for drawing names or shuffling a playlist |
| Reverse the current order | Does not sort. The last line becomes the first |
Why numeric order exists
Alphabetical sorting compares text character by character, so the line "item 10" comes before "item 2", because the character 1 is smaller than 2. Numeric order reads the number instead, which gives the order a human expects. That is why a list of invoices, versions or scores should use numeric order, not A to Z.
Worked example
- Paste
banana,apple,cherry,apple,datein Your lines and keep A to Z. The Sorted lines areapple,apple,banana,cherry,date: 5 lines in and 5 out. - Tick Remove duplicate lines. The result becomes
apple,banana,cherry,date, and Lines in result shows 4. - Replace the text with
item 10,item 2,item 1,notes. With A to Z you get item 1, item 10, item 2, notes. With Numeric, smallest first you get item 1, item 2, item 10, notes, with the line without a number at the end.
The cleaning options
- Ignore uppercase/lowercase is on by default, so Banana and banana are treated as equal for sorting and for duplicate detection. When two lines are equal this way, they keep their original order.
- Remove duplicate lines keeps the first copy of each line.
- Remove empty lines is on by default. Untick it if blank lines carry meaning, for example between groups.
Tips and common mistakes
- Sorting rearranges whole lines only. A table with several columns on one line is sorted by its first characters, so put the column you want to sort by first.
- Each run of Random (shuffle) gives a different order, so copy the result you want to keep.
- If your numbers have different formats, such as 1.500 and 1,5, check the result by eye. The tool reads one comma or point as a decimal mark.
- Use Reverse the current order after sorting A to Z if you want the same effect as Z to A, or on its own to flip a list such as a log.
Related tools
For removing repeats without sorting, use the duplicate line remover. To count how many lines or words you have, use the word and character counter, and to compare two versions of a list, use the text diff checker.
Questions
Does alphabetical sorting respect accents?
Yes. It uses your language rules, so letters like é or ñ are placed where a dictionary would put them.
How does numeric sorting work?
It reads the first number in each line, so "item 10" comes after "item 2". Lines with no number go to the end.
What does Random do?
It shuffles the lines into a new random order each time the result is recalculated.
Does Reverse sort the list?
No. It only flips the current order: the last line becomes the first.