Text Sorter

Sort any list of lines into alphabetical order, reverse alphabetical, shortest-first, longest-first, or a random shuffle. Options to remove duplicate lines and toggle case sensitivity let you fine-tune the result before copying.

Enter a list above to sort it

How It Works

Sorting text is one of the most common data-cleaning tasks. Whether you're ordering a list of names, organising CSS selectors, or shuffling a deck of words, the right sort can save significant manual effort.

A–Z (alphabetical): Lines are sorted using the natural Unicode sort order. By default the sort is case-insensitive, so "Apple", "banana", and "Cherry" sort as apple < banana < cherry. Enable the "Case sensitive" toggle if you need uppercase letters to sort before lowercase ones (ASCII order: "Cherry" < "apple" < "banana").

Z–A (reverse alphabetical): The same as A–Z but in descending order. Useful when you want the highest-priority or most-recently-added items at the top of a list.

Shortest first: Lines are ordered by character count, shortest to longest. Lines of equal length keep their relative order (stable sort). Handy for finding the minimal items in a list.

Longest first: Lines ordered from most characters to fewest. Useful when you want the most verbose entries at the top, for example when reviewing variable name lengths.

Shuffle: Lines are rearranged in a random order using the Fisher-Yates algorithm — a proven method that produces a uniformly random permutation. Each click produces a different result. Useful for randomising quiz questions or study flashcards.

Remove duplicates: When checked, only the first occurrence of each line is kept. The comparison respects the "Case sensitive" toggle — if case-insensitive, "Apple" and "apple" count as the same line.

Example:
Input:
banana
Apple
cherry
banana
apple

After A–Z with "Remove duplicates" (case-insensitive):
Apple
banana
cherry

Frequently Asked Questions

Does the sorter keep blank lines?

Blank lines at the start and end of the input are trimmed. Blank lines within the list are kept and treated as empty strings, which sort before any non-empty line in A–Z mode.

What does "case sensitive" affect?

In case-sensitive mode, uppercase letters sort before lowercase in ASCII order (A–Z before a–z). In case-insensitive mode (default), "Apple" and "apple" are treated as equal during sorting. It also affects the "Remove duplicates" option: case-insensitively, "Apple" and "apple" are considered duplicates.

How does the shuffle work?

The shuffle uses the Fisher-Yates algorithm, which visits each line from the last to the first and swaps it with a randomly chosen earlier line. This produces a statistically uniform random order.

Can I sort numbers?

The sorter uses lexicographic (text) sorting, not numeric sorting. So "10" sorts before "9" in A–Z mode. For numeric sorting, place each number on its own line and note this limitation — a dedicated number-sorting tool would be needed for pure numeric order.

Is there a line limit?

No hard limit. The sort runs entirely in your browser, so very large lists (tens of thousands of lines) may take a moment but will complete correctly.