Sort Lines
Paste any list of lines and get them sorted alphabetically, numerically, by length, or randomly shuffled. Reverse order, case sensitivity, and natural-sort (the one that puts file2 before file10) are all toggleable. Works on lists pasted from spreadsheets, log files, terminal output, or any newline-delimited text.
Why Sorting Lines Is a Daily Task
Half the small text-wrangling jobs that come up in a workday are some flavour of sort. A list of email addresses needs to go in alphabetical order for a mail merge. A column copy-pasted from a CSV needs to be sorted before being de-duplicated (see the remove duplicate lines tool for the next step). A list of filenames needs natural order so image10.jpg doesn't come between image1.jpg and image2.jpg. Each of these takes about five seconds with the right tool and five minutes without one.
The classic Unix sort command handles all of these and more, but pulling text out of a browser, into a terminal, through sort, and back into the browser is enough friction that most people give up and live with unsorted lists. A web-based sorter removes the friction.
How It Works
The tool splits the input on line breaks and sorts with the browser's Intl.Collator, so alphabetical order follows your browser's language and handles accented letters and non-Latin scripts. Numerical mode switches on the collator's numeric option, which compares runs of digits by value (natural sort: item-2 before item-10); it does not read minus signs or decimals as numbers. Length sorts count characters; Reverse flips the current order; Shuffle uses a Fisher-Yates shuffle.
Random shuffle uses the Fisher-Yates algorithm seeded with crypto.getRandomValues(), which is the same source the UUID generator uses. The result is statistically uniform, which matters if you're using the sort to randomize survey question order, draw a sample, or pick a winner from a list of entries.
Common Use Cases
Alphabetizing a list of names before importing into a CRM. Sorting log entries by timestamp prefix to spot the chronological gap. Putting CSS class names in alphabetical order so the diff shows actual changes, not rearrangements. Generating a random play order for a music queue. Ordering URLs before passing them to a sitemap generator. Putting a glossary in order before publishing.
Worked example: what "numerical" and "alphabetical" actually do
Both main modes use the browser's Intl.Collator. Numerical simply switches on its numeric option, which compares runs of digits by value. It's natural sort, not number parsing. On October 12, 2026 we ran the tool's own sort function on two test lists and compared the results with GNU sort.
| Input | This tool | Reference |
|---|---|---|
| Numbers: 10.25, 10.5, −5, −10, 2, 1e3, 3 (Numerical mode) | −5, −10, 1e3, 2, 3, 10.5, 10.25 | sort -g: −10, −5, 2, 3, 10.25, 10.5, 1e3 |
| Files: image10.jpg, image2.jpg, Image1.jpg, image1.jpg (A–Z, ignore case) | image1.jpg, Image1.jpg, image10.jpg, image2.jpg | LC_ALL=C sort: Image1.jpg, image1.jpg, image10.jpg, image2.jpg |
What that means in practice:
- Numerical mode is right for whole, positive numbers and for names with numbers in them (file2 before file10, version 1.9 before 1.10). It treats the minus sign and the decimal point as ordinary characters, though: −5 comes before −10, 10.5 before 10.25 (because 5 < 25), and 1e3 sorts as "1". For real numeric data use the Number value modes, added on October 13, 2026: they read the number at the start of each line (or of the chosen column) as a value, signs, decimals and exponents included. On a 24-line test list (negatives, decimals, exponents, "10 apples", blank and text lines) Number value ↑ gave exactly the order of GNU sort -g -s, and Number value ↓ that of sort -g -r -s; lines without a leading number go first (last when descending), as sort -g does.
- A–Z is not ASCII order. Even with case-sensitivity on, the collator places "a" and "A" next to each other rather than putting every capital first, as byte-order tools do. That's usually what you want for names and lists, but it won't match a sort done with
LC_ALL=Cor in most programming languages' default string sort. - A–Z depends on the visitor's language. The collator uses your browser's locale. We sorted zebra, öl, apple, Äpfel and ångström. English and German interfiled the accented words among the a's and o's. Swedish put å, ä and ö after z, as its alphabet does. Two people sorting the same accented list can get different orders.
Shuffle uses a Fisher–Yates pass driven by crypto.getRandomValues() with rejection sampling (since October 14, 2026; it used Math.random() before). In 240,000 shuffles of four lines all 24 orders appeared between 9,784 and 10,191 times (chi-square 27 against a 1% critical value of 41.6), so every order is equally likely and the next shuffle cannot be predicted from earlier ones. Equal keys keep their original order: the column and ignore-prefix sorts use the original position as an explicit tie-breaker, and JavaScript's Array.prototype.sort has been required to be stable since ECMAScript 2019.
Sources
Checked on .
- ECMA-402 Internationalization API: Intl.Collator (numeric, sensitivity)
- MDN, Intl.Collator() constructor
- Unicode Technical Standard #10: Unicode Collation Algorithm (tailorings per language)
- GNU coreutils manual: sort (-g general numeric sort)
- ECMAScript Language Specification: Array.prototype.sort (stability)
Frequently Asked Questions
Related Tools
Related ToolRemove Duplicate Lines →📖 Learn More
Related Guide How to Sort Lines of Text →Built by Derek Giordano · Part of Ultimate Design Tools