Sort Text Lines
Sort lines alphabetically or by length
About Sort Text Lines
Sort Text Lines reorders the lines of a list. Sort A–Z and Sort Z–A follow dictionary order in the language of your browser: capitals and lower case sort together, accented letters sit next to their base letter in most languages, and numbers inside a line are compared by value. Sort by length goes from shortest to longest. The two Sort by number buttons read the number at the start of each line, decimals and minus signs included. Shuffle puts the lines in random order. It sorts whole lines, not words, in your browser.
Example
Sort A–Z: case is ignored, é sorts with e, and item 2 comes before item 10.
Lines
item 10 Banana zebra éclair apple item 2
After "Sort A–Z"
apple Banana éclair item 2 item 10 zebra
How to sort lines of text
- 1Paste the lines to reorder, for example names, file names, or numbers.
- 2Click "Sort A–Z", "Sort Z–A", "Sort by length", "Shuffle", "Sort by number (0–9)", or "Sort by number (9–0)".
- 3Take the sorted list with "Copy", or "Download" it as sorted.txt.
Formats and limits
- Alphabetical
- Case-insensitive, accents second, numbers by value, in your browser's language
- By number
- Number at the start of each line, with sign, decimals, and exponent; other lines follow in A–Z order
- By length
- Characters as displayed, shortest first; equal lengths in A–Z order
- Output
- Sorted lines as one text block with Unix line breaks, copied or downloaded as sorted.txt
Where your text is processed
Sorting uses the collator built into your browser and, for Shuffle, its cryptographic random generator. The lines never leave the page and are not stored. Should a copy to the clipboard fail, our error log receives that error message with the tool name and browser version, never the lines themselves.
Frequently asked questions
Does item 10 sort after item 2?
Yes. Sort A–Z compares runs of digits by value, as file managers do, so file2 comes before file10. For a list of plain numbers with decimals or minus signs, use "Sort by number (0–9)": -10, -2, 1.25, 1.3, 1.5.
Is sorting case-sensitive?
No. apple, Banana, and cherry sort together, as in a dictionary. When two lines differ only by case or accents, a second comparison decides between them, so the result is the same every time.
Do accented letters sort next to their base letter?
Yes, in English, French, German, and most other languages: éclair comes before zebra. The order follows the language of your browser, so in Swedish or Danish å, ä, ö, æ, and ø come after z, as in those alphabets.
Is Shuffle really random?
Yes. It is a Fisher-Yates shuffle fed by crypto.getRandomValues, the cryptographic generator of the browser. Because each draw is a 32-bit number, a modulo bias remains, at most n in 4,294,967,296 for a list of n lines.
Tips and tricks
- ✓Remove repeated lines first with Remove Duplicate Lines, then sort the shorter list here.