Sort lines of text A-Z, Z-A, by length, in reverse, or shuffled at random — with case-sensitivity and empty-line options, updating live as you type.
A plain list of lines — file names, CSS classes, changelog entries, product SKUs, quiz questions — carries meaning through its order just as much as through its content. An alphabetized list is faster to scan and search visually; a length-sorted list groups similar-sized entries together, which is useful for spotting outliers or formatting fixed-width output; a shuffled list removes any bias that comes from original ordering (early items in a list get more attention, on average, than later ones — a well-documented effect in surveys, testing, and UX research). This tool exists to make reordering a plain-text list a one-step, zero-setup task instead of something you'd otherwise do by pasting into a spreadsheet or writing a throwaway script.
Alphabetical sorting (A-Z and Z-A) relies on JavaScript's locale-aware string comparison, which orders text the way a person naturally would — handling accented characters, numbers, and mixed case sensibly rather than by raw character codes alone (unless you explicitly enable Case sensitive mode, which switches to exact, code-point-based ordering). Length-based sorting compares the character count of each line directly; since JavaScript's array sort is guaranteed stable, lines of identical length keep their original relative order rather than being shuffled arbitrarily. Reverse simply flips the array end-to-end with no comparison logic involved at all — the fastest and most predictable of all the modes.
It's tempting to shuffle a list by assigning each item a random number and sorting by it, but that naive approach is subtly biased — it doesn't produce every possible ordering with truly equal probability, especially with certain comparison functions or duplicate random values. The Fisher-Yates shuffle, used by this tool, avoids that trap entirely: it walks backward through the list once, and at each position, swaps the current item with a uniformly-random item from the remaining unshuffled portion. This guarantees every one of the n-factorial possible orderings of an n-item list is equally likely, it runs in linear time (a single pass), and it's the algorithm of choice in virtually every serious shuffling implementation, from card games to A/B test assignment.
When sorting lines that mix text and numbers — like 'item 2', 'item 10', 'item 1' — be aware that standard alphabetical sorting treats numbers as text, so 'item 10' will sort before 'item 2' (because '1' comes before '2' character by character). This is expected, standard string-sort behavior, not a bug, but it's worth knowing before you rely on the output. For genuinely numeric ordering, you'd want each line to start with a zero-padded number ('item 02', 'item 10') so the character-by-character comparison lines up with numeric order. For deduplication before or after sorting, pair this tool with Remove Duplicate Lines; for cleaning up whitespace or blank entries first, the Remove empty lines toggle here handles the most common case directly.
Text Line Sorter reorders your lines without touching their content. These related text tools handle other common line- and list-based cleanup tasks.