Text line sorter

Sort any list of lines alphabetically, by length, numerically, or randomly. Instant results.

Sort by:
Input
Output
Send output to:

Ctrl + L clear  |  Ctrl + Shift + C copy output

About sorting

Putting things in order is one of humanity's oldest information technologies. Alphabetization was already in use at the Library of Alexandria over two thousand years ago, where the scholar Callimachus catalogued 120,000 scrolls in his Pinakes. Mechanical sorting arrived with Herman Hollerith's punched-card machines, built to tame the 1890 US census — the company he founded became IBM. And in computer science, sorting is the canonical problem: more algorithmic research has gone into sorting than almost any other task, precisely because ordered data is the foundation of fast searching. This tool applies all of that heritage to the humble everyday list.

Sort modes explained

Alphabetical A to Z sorts lines from the beginning of the alphabet to the end using standard dictionary ordering. Z to A is the reverse. Shortest first puts the briefest lines at the top of the list — useful for formatting menus, navigation items, or any list where you want a clean visual progression from short to long. Longest first does the opposite and is useful when you want the most detailed entries at the top.

Numeric sort is essential when your list contains numbers. Standard alphabetical sorting would order "1, 10, 2, 20, 3" because it compares characters one at a time. Numeric sort correctly orders them as "1, 2, 3, 10, 20" by their actual numeric value. Random shuffle randomizes the order completely — useful for randomizing a list of names, options, or items when you need an unbiased order.

Common uses for line sorting

Writers sort lists of items alphabetically before adding them to articles or reference sections. Developers sort import statements, CSS properties, or configuration keys to keep code organized. SEO professionals sort keyword lists by length or alphabetically before uploading to tools. Data analysts sort exported data before processing. Teachers randomize lists of student names for fair assignment of tasks.

Frequently asked questions

How do I sort lines of text alphabetically?

Paste your list — one item per line — and click A-Z; the sorted result appears instantly, with Z-A giving reverse order. Two options are worth enabling for messy real-world lists: trim whitespace, so items with stray leading spaces do not all cluster at the top, and remove blank lines, so gaps in the pasted list disappear from the output. This beats sorting in a spreadsheet when the list lives in a document or code file rather than a table.

Can I sort lines by length?

Yes — shortest first or longest first. Length sorting has surprisingly practical uses: menus and navigation labels look deliberate when arranged in a smooth visual taper, CSS and code style guides sometimes order properties by length, and sorting longest-first is the quickest way to find the outliers in a list — the over-long product titles, the meta descriptions that will truncate, the one absurdly long line breaking your layout.

Does the sorter handle numbers correctly?

Yes, in numeric mode. Plain alphabetical sorting compares characters one at a time — lexicographic order — which files "10" before "2" because the character 1 precedes 2, producing the notorious "1, 10, 11, 2, 20" sequence familiar from badly sorted file lists. Numeric sort parses each line's numeric value instead, yielding the natural 1, 2, 10, 11, 20 order. Use it whenever your lines start with or consist of numbers: prices, IDs, versions, quantities.

Can I randomize the order of lines?

Yes. Random shuffle rearranges all lines into a new random order on every click, so hitting Reshuffle repeatedly deals fresh arrangements without re-pasting. Shuffling is the fair-play tool of list processing: teachers randomize student name lists for presentations, researchers randomize question order, and anyone running a draw can shuffle entrants and take the top of the list as winners without any bias creeping in from the original order.

Is the sorting case sensitive?

By default, no — "apple" and "Apple" sort side by side, which matches what people expect from a dictionary-style ordering. Enable case sensitive mode and sorting follows raw character codes instead, where all uppercase letters precede all lowercase ones (ASCII order): "Zebra" then sorts before "apple". That mode matters when your list is code, where identifiers differing only by case are genuinely different, or when you need output to match how Unix sort or a programming language would order the same lines.