Skip to content

Sort Lines Alphabetically and Remove Duplicates

Sort lines alphabetically (A–Z, Z–A, by length or number), shuffle them, and remove duplicate lines, with dictionary order for your language. Runs in your browser.

Runs in your browser

Everything happens on your device: nothing you paste or type is sent to our server or stored. A share link holds your settings, and your input only if you choose to include it.

Dictionary order follows the Unicode Collation Algorithm and the language’s rules. Character code order puts every capital before every small letter, like the sort command in the C locale.

Off, digits are compared one at a time, so file10 comes before file2.

Apple and apple then count as duplicates, and sort together.

Puts the count and a tab before each line, like sort | uniq -c. Pastes into a spreadsheet as two columns.

More options

60 characters · 61 bytes (UTF-8) · limit 5 MB

Output: 60 characters.

Lines in
8
Lines out
8
Different lines
7
Blank lines removed
0

Method: Unicode Collation Algorithm (UTS #10) with CLDR rules for en, via Intl.Collator · FindMySum (no library)

Off by default. When on, your input is packed into the part of the link after “#”, which browsers never send to any server; anyone you give the link to will see it.

How it works

The tool splits your text into lines, trims spaces at either end and drops blank lines (both can be turned off under More options), then handles duplicates and finally sorts. Two lines count as duplicates when they are identical, or identical apart from capitals if you tick that option; an accented letter typed as one character or as a letter plus an accent mark counts as the same line.

Dictionary order follows the Unicode Collation Algorithm (UTS #10) with the language rules from the Unicode CLDR project, through your browser's built-in Intl.Collator: letters are compared first, then accents, then capitals, so a, B and c sort in that order, and each language's own alphabet applies (in Swedish, å, ä and ö come after z). Character code order compares the numbers behind each character, the way the sort command does in the C locale, which puts every capital letter before every small one. Sorting numbers by value treats a run of digits as one number, so file2 comes before file10.

The sort is stable: lines that compare as equal stay in the order you gave them. A shuffle uses a numbered sequence, so the same shuffle number always gives the same order and a shared link reproduces it. Everything runs in your browser.

Standards this tool follows

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.

Sources

Frequently Asked Questions

Why does Zebra come before apple in some sorted lists?

That list was sorted by character code. In that order every capital letter comes before every lower-case one, because capitals have smaller codes. Dictionary order, the default here, ignores capitals unless two words are otherwise the same, so apple comes before Zebra.

How do I remove duplicate lines without changing the order?

Set the order to Keep the current order and duplicates to Remove duplicates. The first copy of each line stays where it was and later copies are removed. Tick the capitals option if Apple and apple should count as the same line.

Can I sort numbers with this tool?

Yes. Turn on Sort numbers by value so that 9 comes before 10 and file2 before file10. Without it, digits are compared one at a time, as text, which puts 10 before 9. Decimal numbers and negative signs are compared as text, so for a column of measurements a spreadsheet is the better choice.

Is my list uploaded anywhere?

No. The sorting happens in your browser, so lists of names, emails or other private data never leave your device. A share link includes your lines only if you tick the box for it.

Spotted a wrong result or a bug? Report a problem (the link sends the page address only, never what you entered).

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy