Sort Lines Alphabetically and Remove Duplicate Lines
By FindMySum · Last reviewed
Paste a list with one item per line and this tool will sort lines alphabetically as you type, from A to Z or Z to A, by length, or by the numbers they contain. It can also remove duplicate lines, show only the duplicates, count how often each line appears, or shuffle the list. It runs in your browser, so nothing in your list is uploaded.
What you can do with it
- Alphabetise a list of names, products, tags or references, in dictionary order for your language.
- Clean up a mailing list or a set of keywords by removing duplicate lines, with or without matching capitals.
- Find repeated entries with the show-only-duplicates option, or see how many times each line appears, which pastes into a spreadsheet as two columns.
- Order file names or version numbers naturally, so chapter 2 comes before chapter 10.
- Shuffle a list for a draw or a random running order. Change the shuffle number for a different order.
A worked example
Suppose you paste these six lines: banana, Apple, cherry, apple, file10.txt and file2.txt. In English dictionary order the result is apple, Apple, banana, cherry, file10.txt, file2.txt: the two apples sort together, with the small letter first, because capitals only matter when the letters are otherwise identical. Switch to character code order and Apple jumps to the top, ahead of every lower-case word. Turn on sorting numbers by value and file2.txt moves ahead of file10.txt. Choose to remove duplicates with capitals ignored, and only the first of the two apples remains.
Tips and common mistakes
Check the language. Several languages sort letters differently from English. Swedish, Finnish and Danish put letters with rings and dots after z, Spanish treats ñ as a separate letter after n, and Turkish has a dotted and a dotless i. Pick the language of your list for the order its readers expect.
Watch the spaces. A line with a trailing space is a different line from one without, which is why trimming is on by default. Turn it off when spacing matters, such as for indented code.
Numbers with decimals. Natural order reads 1.5 as the number 1, a full stop and the number 5, which works for version numbers but not for prices. Sort measurements in a spreadsheet instead.
To change the capitals in your list before sorting, use the case converter; to count the words in it, the word counter; and to pick random winners rather than shuffle a whole list, the random number generator.