PlayTools

Sort Text Lines

Sort lines alphabetically, numerically, by length, in reverse or shuffled, with options to trim, drop blanks, remove duplicates and ignore case.

Runs in your browser — nothing you enter is uploaded

Alphabetical sorting is locale-aware and natural: “item2” comes before “item10”. Number mode reads the leading number on each line and ignores the rest, so “3. Apples” sorts by 3. Length ties fall back to alphabetical order. Everything runs in your browser.

Advertisement

Sorting lines: alphabetical, natural, numeric

Sorting a list of lines is one of those tasks that is trivial until the details bite. Plain ASCII sorting puts "Item10" before "Item2" because it compares character by character and "1" comes before "2". This tool uses natural, locale-aware comparison by default, so numbers embedded in text sort the way a human expects.

The modes cover the common needs. A→Z and Z→A are lexical. Number mode ignores everything except the first number on each line — handy for lists like "3. Apples" or "12) Oranges" where the label, not the text, is the key. Length mode is useful for finding the longest or shortest entries, with ties broken alphabetically. Reverse simply flips the current order, and Shuffle randomises it with a Fisher–Yates pass.

The cleanup options run before the sort. Trimming each line removes stray leading and trailing spaces that would otherwise affect both comparison and appearance. Dropping blank lines removes the gaps that accumulate when you paste from a document. Removing duplicates keeps only the first occurrence of each line. Case-insensitive comparison groups "Apple" and "apple" together instead of separating all capitals from all lowercase.

Typical uses: alphabetising a glossary or bibliography, ordering CSV rows by a leading ID, tidying an import list, de-duplicating and sorting a keyword list, or generating a random running order for a playlist or a set of tasks. For heavy deduplication work, the dedicated Remove Duplicate Lines tool gives you more control over which copy to keep.

Everything happens in your browser — nothing is uploaded, and the tool works offline once loaded.

These free tools pair well with this page — open them in a new tab to finish your workflow.

Advertisement

Frequently Asked Questions

How does alphabetical sorting handle numbers in the text?

The A→Z and Z→A modes use natural, locale-aware ordering, so "item2" sorts before "item10" rather than after it. If you want to sort purely by a leading number and ignore the rest of the line, use the Number modes instead.

What does Number mode sort on?

It reads the first number it finds at the start of each line — integer or decimal, with an optional minus sign — and orders by that value. "3. Bananas" and "3) Bananas" both sort as 3. Lines with no leading number are treated as 0.

Is the sort case-sensitive?

By default it is case-insensitive, so "apple" and "Apple" sort together. Untick "case-insensitive" to get ASCII-style ordering where uppercase letters come before lowercase.

What do "trim" and "drop blank lines" do?

"Trim each line" removes leading and trailing spaces before sorting and from the output. "Drop blank lines" removes empty lines entirely. Both are on by default because they usually give a cleaner result for pasted lists.

Can it remove duplicates at the same time?

Yes. Tick "remove duplicates" and only the first occurrence of each line is kept, then the sort is applied. For a dedicated deduplication tool with more control, use Remove Duplicate Lines.

Does Shuffle give a truly random order?

It uses a Fisher–Yates shuffle seeded by the browser's Math.random, which is fine for reordering a list, picking a random running order, or breaking alphabetical bias. It is not cryptographically random — do not use it for anything security-sensitive.

Is my text uploaded?

No. All sorting happens in your browser and nothing is sent to a server. The tool works offline once the page has loaded.