Sort Lines Online - A to Z, Numeric, by Length, Reverse or Shuffle
Paste a list and sort it as you type: A to Z, Z to A, by the number at the start of each line, by length, in reverse, or shuffled.
Maintained by Hirantha Sandaruwan Lakshan. Updated 13 October 2026.
About this tool
Numbers inside text can be put in numeric order so item2 comes before item10, case and spaces can be ignored, and text is ordered by the rules of the language you choose. Hundreds of thousands of lines are fine, and nothing is uploaded.
How it works
Lines are split at every line break: Windows, Unix and old Mac endings, and the Unicode line and paragraph separators. A single break at the very end of the text ends the last line. It is not sorted as an empty line, and it is put back at the end of the result. In A to Z order empty lines come first unless you tick 'Remove empty lines'. Lines that compare as equal keep their original order, because JavaScript's sort has been required to be stable since ECMAScript 2019.
Text is ordered with Intl.Collator, the language-aware comparison built into your browser. By default it compares base letters first, then accents, then case. For English and most other languages it puts lower case before upper case when everything else is equal (a before A), as the default table of the Unicode Collation Algorithm does (UTS #10, section 6.6, gives 'a' and 'A' different tertiary weights with a first). A few languages, such as Danish, reverse that and put capitals first, and UTS #10 section 9.6 notes that this varies by language. Pick a language to change the rules: in Swedish the letters å, ä and ö come after z, while in German ä sorts with a. 'Ignore upper and lower case' makes a and A equal. If your browser has no rules for the language you pick, the tool says so and uses its default language, and if it cannot build a collator at all it falls back to code point order.
'None: Unicode code point order' compares plain Unicode values. Every capital letter comes before every lower case letter (Z before a), accented letters come after z, and with 'Ignore spaces' and 'Ignore case' off the result matches what the Unix sort command gives in the C locale. It is predictable but not what a reader expects of an alphabetical list. This mode compares real code points. JavaScript's own default sort compares UTF-16 code units, which puts characters outside the Basic Multilingual Plane, such as most emoji, before some characters that have a lower code point.
'Numbers inside text in numeric order' compares each run of digits by its value, so item2 comes before item10 (natural sort order). The two 'Numbers' orders read the number at the start of each line instead: an optional sign, thousands commas, a decimal point and an exponent, so -10 comes before -5 and 1,200 comes after 999. Lines with no number at the start go last in their original order. Numbers are read as ordinary decimals, so digits beyond about 15 lose precision; for long IDs use the numeric option on text. 'Shortest first' and 'Longest first' count Unicode characters, so an emoji is one, and lines of equal length are in A to Z order. Shuffle is a Fisher-Yates shuffle driven by the seed you can see, so a shuffle can be repeated; it uses a fast 32-bit generator, which is fine for rearranging a list and not for a draw that must be unpredictable.
Worked examples
Towns, A to Z
Colombo, Galle, Kandy, Jaffna, anuradhapura, Matara, badulla and Negombo become anuradhapura, badulla, Colombo, Galle, Jaffna, Kandy, Matara, Negombo. Capital and small letters are mixed together, as in a dictionary, not capitals first.
File names in natural order
With 'Numbers inside text in numeric order' on, report10.pdf, report2.pdf, Report1.pdf, report20.pdf and report3.pdf become Report1.pdf, report2.pdf, report3.pdf, report10.pdf, report20.pdf. Without it, report10 would come before report2.
A list of numbers
42, 7, -3, 1,200, 3.5, 100 and n/a with 'Numbers, smallest first' become -3, 3.5, 7, 42, 100, 1,200, n/a. The line with no number goes last.
Reverse, shuffle and ties
Reverse order simply turns the list upside down. Shuffle gives a new order for each seed. In 'Shortest first', 'ab' and 'cd' are the same length, so they are listed in A to Z order.
Zebra, apple, Éclair, item10, item2, Apple and 9 in four orders (English rules except the last)
| Order | Result |
|---|---|
| A to Z | 9, apple, Apple, Éclair, item10, item2, Zebra |
| A to Z, natural numbers | 9, apple, Apple, Éclair, item2, item10, Zebra |
| A to Z, ignore case | 9, apple, Apple, Éclair, item10, item2, Zebra |
| Unicode code point order | 9, Apple, Zebra, apple, item10, item2, Éclair |
Frequently asked questions
How do I sort lines alphabetically?
Paste the lines into the box and leave the order on 'A to Z'. The result is ready at once. 'Z to A' reverses the order, and 'Reverse order' simply turns the list upside down without sorting it.
Why does item10 come before item2?
Plain text order compares one character at a time, and the character 1 comes before 2. Tick 'Numbers inside text in numeric order' and each run of digits is compared as a whole number, so item2 comes before item10. This is called natural sort order.
Why do some tools put all capitals before lower case?
They compare Unicode values, where every capital letter is lower than every small letter, so Zebra comes before apple. This tool uses language rules by default, which mix the cases like a dictionary. Choose 'None: Unicode code point order' if you want the plain comparison.
How do I sort numbers?
Choose 'Numbers, smallest first' or 'Numbers, largest first'. The tool reads the number at the start of each line, with a sign, thousands commas and decimals allowed. A line such as '10 apples' sorts by 10. Lines with no number at the start go last.
How do I sort accented or Sinhala text properly?
Pick the language under 'Language rules for text'. The tool then uses your browser's ordering rules for it. If the browser has none for that language, a message says so. Different languages order the same letters differently, for example Swedish puts ä after z and German does not.
Can I sort and remove duplicates together?
Sort the list here, then paste it into Remove duplicate lines. For exact duplicates the order of the two steps does not matter. If you also ignore case or spaces, the copy that stays can differ: Remove duplicate lines keeps the first copy in the order it receives, so sorting first keeps the first copy in sorted order.
Is the shuffle truly random?
It is a fair Fisher-Yates shuffle, repeatable from the seed shown, and 'Shuffle again' picks a new seed with your browser's secure random generator. The shuffle itself uses a 32-bit generator, so do not use it for a prize draw or anything else that must be unpredictable.
How many lines can it sort?
Up to 5 million characters at once, about 5 MB of plain text. In testing on a small server, 200,000 random lines of 5 to 34 characters sorted in under a second. A longer text is refused with a message and nothing is changed.
Is my list uploaded?
No. Sorting happens in your browser and nothing is sent anywhere. You can also open a text file from your device, which is read locally.
Sources & references
- Intl.Collator() constructor - MDN Web Docs (sensitivity, numeric, caseFirst), checked 13 October 2026
- Array.prototype.sort() - MDN Web Docs (stable since ECMAScript 2019; default order is by UTF-16 code units), checked 13 October 2026
- Unicode Technical Standard 10, Unicode Collation Algorithm (section 6.6: a sorts before A by default), checked 13 October 2026
- Natural sort order - Wikipedia (file1.txt, file2.txt, file10.txt example), checked 13 October 2026
- Swedish alphabet - Wikipedia (the alphabet ends with z, å, ä, ö), checked 13 October 2026
Updated Oct 13, 2026