Skip to content

Sort Lines Alphabetically

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.

InputThis toolReference
Numbers: 10.25, 10.5, −5, −10, 2, 1e3, 3 (Numerical mode)−5, −10, 1e3, 2, 3, 10.5, 10.25sort -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.jpgLC_ALL=C sort: Image1.jpg, image1.jpg, image10.jpg, image2.jpg

What that means in practice:

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 .

Frequently Asked Questions

Does this tool upload my text?+
No. All sorting happens in your browser. Your text never leaves your device.
What sort options are available?+
A-Z and Z-A; natural numerical ascending and descending (digit runs compared by value, good for file2 / file10); Number value ascending and descending (the leading number read as a value, like sort -g); by line length (shortest or longest first); reverse order and shuffle. Options: ignore case, remove blank lines, ignore leading bullets and quotes, and sort by a delimited column.
Does it handle international characters?+
Yes. Sorting uses locale-aware comparison, which correctly handles accented characters, non-English alphabets, and mixed-language text.
Can I sort numbers correctly?+
Yes: use Number value ↑ or ↓. They read the number at the start of each line (or column) including signs, decimals and exponents, so −10 comes before −5, 10.25 before 10.5 and 1e3 counts as 1000; on our test list the order matched GNU sort -g exactly. The natural numerical mode is for names with numbers in them (image2 before image10). Thousands separators such as 1,000 are not read as one number.
Can I sort while ignoring leading whitespace or symbols?+
Yes. "Ignore leading bullets & quotes" skips leading spaces, tabs, hyphens, asterisks, bullet dots and straight or curly quotation marks when comparing, so "- banana" sorts next to "banana". The lines themselves are output unchanged.
Does it remove duplicate lines?+
No. Sort first, then use the Remove Duplicate Lines tool, which has exact and case-insensitive options.
What happens to blank lines?+
They are kept and sorted with everything else (usually ending up at the top) unless you turn on Remove blank lines. There is no option to sort within blank-line-separated blocks.
Can I sort by a specific column or field?+
Yes. Turn on "Sort by column", pick the delimiter (comma, tab or a custom string) and the column number, counting from 1. Lines are compared on that field only and keep their full text in the output; lines with equal keys stay in their original order. The split is a plain delimiter split, so a quoted CSV field that itself contains commas is not treated as one field; use the CSV Viewer for quoted CSV.

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

Privacy Policy · Terms of Service