Text Sorter

Sort text lines alphabetically or reverse order. Free text sorting tool for lists and data.

Sort:
4 lines
4 lines

How the Text Sorter Works

Paste your list, one item per line, pick a sort mode from the pill row, and the right-hand panel updates instantly. Five modes are available: A-Z, Z-A, shortest first, longest first, and random. The line counter under the input shows how many non-empty lines you started with, and the matching counter on the output side confirms nothing was lost. Click Copy to grab the sorted result.

Alphabetical sorting uses JavaScript's localeCompare with case-insensitive matching, so 'Apple' and 'apple' end up next to each other rather than separated by all the lowercase entries. Length sorting counts every character including spaces, so 'New York' sorts as eight characters. Random mode runs a Fisher-Yates shuffle, which is unbiased: every possible ordering is equally likely. The Reshuffle button generates a fresh permutation without you having to switch modes.

Real Sorting Scenarios

A teacher with a roster of 28 pupil names pastes them into the input, picks A-Z, and has an alphabetised register in two seconds. An event organiser with a guest list sorted by 'longest first' immediately sees which names will need wider place cards. A YouTuber drafting a giveaway runs random mode, hits Reshuffle, and announces the first three lines as the winners. None of these tasks need a spreadsheet.

Trip-ups to watch for: leading spaces or tabs change A-Z order, because ' Apple' (with a leading space) sorts before 'Apple' in ASCII order. Run [Whitespace Cleaner](/whitespace-cleaner) first if your list came from a copy-paste with inconsistent indentation. Numbers in alphabetical mode sort lexically, so '10' comes before '2'. If you have a numbered list, prefix each number with a leading zero so the lengths match, or sort by length-short instead.

Frequently Asked Questions

Does it preserve duplicates?

Yes. The sorter does not remove duplicate lines; it just rearranges what you give it. If two pupils share the name 'Smith', both 'Smith' entries will appear next to each other after A-Z sorting. To deduplicate, run the result through [Remove Duplicate Lines](/remove-duplicate-lines) afterwards.

How does it handle accents and non-Latin characters?

localeCompare uses the browser's default locale for ordering, which in most cases produces the result you would expect: 'cafΓ©' sorts after 'cafe' but before 'caffeine'. Cyrillic, Greek, Arabic and CJK scripts are supported and sort correctly within their respective alphabets, but mixing scripts in one list produces locale-dependent results.

Is the random shuffle truly random?

It uses Math.random() which is a pseudorandom generator, not cryptographically secure but more than random enough for shuffling lists of names or items. For a giveaway with high stakes (large prize, public draw), use a verifiable random source like random.org. For everyday use, this is indistinguishable from true random.

What is the upper line limit?

There is no hard cap, but performance becomes noticeable above 100,000 lines because each sort runs in your browser. Up to 10,000 lines is instant. Beyond that, expect a brief pause. For multi-million line files, a desktop tool or scripting language is the right choice rather than a browser.

More tools β†’