Sort Lines
Sort lines of text alphabetically, numerically, by length or in natural order, reverse them or shuffle them randomly. Free and private, in your browser.
How to sort lines
- Paste your list into the input box, one item per line.
- Choose how to Sort by: alphabetical, natural order, numeric value, line length, reverse current order or random shuffle.
- Tick the options you need: Descending, Ignore case, Remove duplicates, Remove empty lines or Trim spaces.
- The sorted list appears in the result box. Click Sort again at any time, for example to get a new random shuffle.
- Copy the result and paste it wherever you need it.
The number of lines and the number of lines removed by the cleaning options are shown under the result.
The sort orders explained
Alphabetical (A → Z) uses real language rules rather than raw character codes. Accented letters are sorted next to their base letter, so “éclair” comes right after “eclair” and before “zebra”, instead of being pushed to the end of the list as a basic sort would do. The sort follows the language of the page, which matters for French, German or Scandinavian words.
Natural order treats groups of digits as numbers. A plain alphabetical sort puts “item10” before “item2” because it compares character by character; natural order gives item1, item2, item10, the way a person would expect. It is ideal for file names, chapter titles and version numbers.
Numeric value looks for the first number in each line and sorts by that value: “2 kg”, “10 kg”, “100 kg”. Negative numbers, decimals (3.5 or 3,5) and thousands separators (1,200 or 1 200) are recognised. Lines that contain no number are kept at the end, in their original order.
Line length sorts from the shortest to the longest line, counting characters. Lines of equal length keep their original order.
Reverse current order flips the list upside down without sorting it: the last line becomes the first.
Random shuffle mixes the lines using your browser’s cryptographic random generator, so every order is equally likely. Use it to draw names, randomise a playlist or shuffle quiz questions. Each click on Sort gives a new shuffle.
Cleaning options
- Descending reverses the direction: Z to A, largest number first, longest line first.
- Ignore case treats “apple” and “Apple” as equal when sorting and when removing duplicates. Without it, lowercase and uppercase versions are kept apart.
- Remove duplicates keeps only the first occurrence of each line.
- Remove empty lines drops blank lines, including lines that only contain spaces.
- Trim spaces removes spaces and tabs at the start and end of every line, which avoids surprises when a stray space changes the sort order.
The line ending of your text (Windows or Unix) is preserved in the result.
Frequently asked questions
Why does "item10" come before "item2"?
That is how a pure alphabetical sort works: it compares “1” with “2” and stops there. Choose Natural order to sort the numbers inside the text by value.
How are lines without numbers handled in numeric sorting?
They are placed after all the lines that contain a number, in the order they had in your input, whether you sort ascending or descending.
Is the random shuffle really random?
Yes. It uses the Fisher–Yates algorithm with the Web Crypto random generator, without the small bias that a naive shuffle introduces. Every possible order has the same chance.
Can I sort and remove duplicates at the same time?
Yes. Tick Remove duplicates and pick any sort order. Combine it with Ignore case and Trim spaces to catch duplicates that differ only by capitals or spaces.
Does sorting change the lines themselves?
No. Apart from the optional trimming, each line is kept exactly as you typed it; only the order changes.
Is my list sent to a server?
No. The sorting happens entirely in your browser, and nothing you paste is uploaded.
Related tools
- Remove Duplicate Lines Remove duplicate lines from any list online. Keep the first occurrence in the original order, with options to ignore case, trim spaces and sort.
- Remove Line Breaks and Extra Spaces Remove line breaks and extra spaces from text copied from a PDF or an email. Keep paragraphs and lists, rejoin hyphenated words, strip quote marks.
- Case Converter Free online case converter to change text to uppercase, lowercase, title case, sentence case, camelCase, snake_case, kebab-case and more.