Skip to content

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 newline characters, builds an array of lines, and applies the chosen comparator. Alphabetical uses the browser's Intl.Collator which respects locale-aware ordering — useful when your data contains accented characters or non-Latin scripts. Numerical sort parses each line as a float and falls back to string sort for non-numeric lines. Natural sort uses a tokenized comparison that treats digit runs as numbers, so item-2 comes before item-10. Length sort orders by character count.

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.

How We Compare

VS Code, Sublime Text, and most modern editors have a sort-lines command built in (in VS Code it's the Command Palette's Sort Lines Ascending). For one-offs outside an editor — or for the natural-sort and length-sort options that most editors don't ship with — a web tool is faster. Spreadsheet apps will sort a column, but require getting the data into the spreadsheet first. This tool handles plain text directly, runs entirely in the browser, and works on lists from a few lines to tens of thousands.

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?+
Alphabetical (A-Z), reverse alphabetical (Z-A), by line length (shortest to longest or longest to shortest), and numerical (natural sort for lines starting with numbers).
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 the numerical sort option for lines that start with numbers. It treats '2' as less than '10' (natural order) rather than alphabetical string comparison where '10' comes before '2'.
Can I sort while ignoring leading whitespace or symbols?+
Yes — the "ignore prefix" option strips leading whitespace, bullet points (-, *, •), and quotation marks before sorting. Useful for cleaning indented or bullet-formatted lists.
Does it remove duplicate lines?+
Optionally — the "dedupe" toggle removes exact duplicates after sorting. The "fuzzy dedupe" mode removes duplicates differing only in case or whitespace.
What happens to blank lines?+
By default they’re removed before sorting. Toggle "preserve blank lines" to keep them as section separators — the tool then sorts within each non-blank block separately.
Can I sort by a specific column or field?+
Yes — toggle "column sort" and pick a delimiter (tab, comma, or custom) plus a column index. Useful for sorting CSV-like rows by a specific field without first running them through a spreadsheet.

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