BrowserTools
Home / Misc / Text Sorter, Sort Lines Alphabetically Online

Text Sorter, Sort Lines Alphabetically Online

Sort a list of lines alphabetically, naturally, by length or numerically. Remove duplicates, shuffle, reverse and number lines, all in your browser.

Loading Text Sorter, Sort Lines Alphabetically Online… If nothing happens, please enable JavaScript.

A text sorter takes a list of lines and puts them in the order you want. Paste anything that is one item per line, a guest list, a set of keywords, log entries, filenames, CSV column values, package names, and the tool reorders it instantly. Alphabetical order is the obvious use, but it is rarely the only one you need: this tool also offers natural order (so file2 comes before file10), sorting by line length, sorting by the first number found in each line, reversing the current order, and a random shuffle. On top of the ordering you can strip surrounding spaces, drop blank lines, remove duplicate entries and number the result, which together cover most of the tidying a raw list needs before you use it somewhere else.

Frequently asked questions

Is my text sent to a server?
No. Sorting, deduplicating and shuffling all happen in your browser with JavaScript. Nothing is uploaded, nothing is stored, and no copy is kept. Once the page has loaded you can even disconnect from the internet and the tool will keep working.
What is the difference between alphabetical and natural sorting?
Alphabetical sorting compares text one character at a time, so file10 comes before file2 because "1" precedes "2". Natural sorting treats digit runs as numbers, so file2 comes before file10, which is how people expect numbered items to be ordered. Pick alphabetical for plain words and natural for anything containing numbers, such as filenames, versions or chapter titles.
How do I remove duplicate lines?
Tick "Remove duplicates". The first occurrence of each line is kept and later repeats are dropped, with a count of how many were removed shown under the buttons. Whether two lines count as duplicates depends on the "Ignore case" option: with it on, "Apple" and "apple" are treated as the same entry.
Does sorting handle accented characters and other alphabets?
Yes. The tool uses your browser's Intl.Collator, the same locale-aware comparison used by operating systems, so accented letters sort next to their base letters instead of after Z, and non-Latin scripts follow their own collation rules. This is a real improvement over a naive comparison that just compares character codes.
Can I sort by number instead of by text?
Yes. The numeric options look for the first number in each line, including negative values and decimals written with a dot or a comma, and sort on that. Lines with no number at all are placed at the end. This is handy for lists like "12 apples" or log lines that begin with a duration or a status code.
Is the shuffle really random?
It uses a Fisher-Yates shuffle with a small seeded generator, which produces a uniform random permutation. The seed only changes when you click "Shuffle again", so the order stays stable while you adjust other options instead of jumping around every keystroke. It is fine for picking names, ordering questions or randomising a playlist, but it is not a cryptographic random source and should not be used where security depends on unpredictability.
How many lines can it handle?
Tens of thousands of lines are no problem on a typical machine, since browsers sort arrays very efficiently. Very large pastes, in the hundreds of thousands of lines, may make the page feel briefly unresponsive because the result recomputes as you type. If you hit that, sort in a couple of smaller batches.
Why does my list look different after sorting even though I did not change the order option?
The tidying options also change the output. "Trim spaces" removes leading and trailing whitespace from each line, "Drop empty lines" deletes blank lines, and "Remove duplicates" deletes repeats. Untick them if you need the lines preserved exactly as pasted.
Can I sort words inside a single line instead of whole lines?
This tool sorts by line, so put each item on its own line first. If your items are separated by commas, replace the commas with line breaks in a text editor (or paste through a find and replace) and then sort. Once sorted you can join them back together.

About Text Sorter, Sort Lines Alphabetically Online

The distinction between alphabetical and natural order is the one that catches people out most often. A plain alphabetical sort compares text character by character, so "file10.txt" lands before "file2.txt" because the character "1" comes before "2". Natural order understands that a run of digits is a number and compares 10 against 2 instead, which is what a human expects when looking at a folder listing or a set of numbered chapters. Both behaviours are correct for different jobs, so both are available here. The same applies to case: with "Ignore case" on, "apple" and "Apple" sit next to each other, which is usually what you want for names and words; with it off, capital letters group first, which matters when you are sorting code identifiers or comparing output against a case-sensitive system.

Using the tool is straightforward. Paste or type your list into the input pane, pick an order, and the output pane updates as you type. Toggle the options to remove duplicates, trim whitespace, drop blank lines or add line numbers. Then copy the result to your clipboard, download it as a .txt file, or press "Result to input" to feed it back in and apply a second pass, for example dedupe first and then shuffle. The shuffle is deterministic per click, so the same list stays put until you ask for another shuffle, and pressing "Shuffle again" gives a fresh random order.

Everything runs locally in your browser using JavaScript, so your list is never uploaded, stored or logged, and the page keeps working offline once it has loaded. That matters when the lines you are sorting are email addresses, customer names, internal hostnames or anything else you would rather not paste into a random web form. Comparison uses your browser's built-in Intl.Collator, which means accented characters and non-English alphabets sort according to proper locale rules rather than raw byte values, so "école" sorts next to "ecole" instead of being pushed to the end of the list.

Sorting Was the First Big Computing Problem

Putting things in order is one of the oldest jobs given to machines. Herman Hollerith's punched-card tabulators, built for the 1890 United States census, included sorting boxes that physically routed cards into bins so clerks could group them by attribute. Half a century later, mechanical card sorters were still the backbone of business data processing, and the word "sort" in computing carries that literal, physical origin: cards moving into separate stacks.

When stored-program computers arrived, sorting immediately became the most studied problem in the field. Merge sort was described by John von Neumann in 1945, one of the earliest non-trivial algorithms written for an electronic computer. Quicksort followed in 1959, invented by Tony Hoare while he was a visiting student in Moscow working on machine translation of Russian text, where he needed to look words up in a dictionary quickly. Donald Knuth eventually devoted an entire volume of The Art of Computer Programming, some 700 pages, to sorting and searching alone. There is a good reason for the attention: sorted data makes searching, deduplicating, merging and summarising dramatically cheaper, so a sort at the start often pays for itself many times over.

Text sorting has a second layer of difficulty that pure number sorting does not: deciding what "alphabetical" even means. Different languages disagree. Traditional Spanish treated "ch" and "ll" as single letters that sorted after "c" and "l". Swedish places a, ä and ö at the very end of the alphabet, after z. German phone books historically sorted ä as if it were spelled ae, while dictionaries sorted it as plain a. To settle this, the Unicode Consortium publishes the Unicode Collation Algorithm along with locale-specific tailorings, and that machinery is what browsers expose through Intl.Collator. When this tool sorts your list, it is quietly using a standard that encodes decades of argument about the alphabet.

Support