TextSorter
0 lines

What Every Button Actually Does

The short version: six buttons reorder your lines, three rewrite them, and every blank line is thrown out before a single comparison runs.

You paste
banana
Apple
cherry
apple
You click A-Z
apple
Apple
banana
cherry
ButtonWhat it does to your lines
A-Z and Z-ACompares lines as text, ascending or descending, the way a dictionary orders words.
1-9Reads a run of digits as one number, so Item 2 lands before Item 10.
LengthShortest line first. Two lines of equal length fall back to alphabetical order.
ShuffleFisher-Yates shuffle seeded by your browser's cryptographic random number generator.
ReverseFlips the current order top to bottom. It does not sort anything.
+ Prefix and Suffix +Attaches a string you type to the start or the end of every line.
123Adds 1., 2., 3. numbering, or strips it back off if line one already looks numbered.

Before any of those run, the tool splits your pasted text on line breaks and drops every line that is empty or made of nothing but whitespace, since a blank line has no content to compare. What survives that filter is the working list each button operates on.

The split between the two halves of that table matters more than it looks. Prefix, Suffix and 123 rewrite the text of each line and leave the order alone. The other six change the order and leave the text alone. That is also why the Remove duplicates checkbox only affects the first six: deduplication runs as the last step of a sort or a shuffle, so there is nothing for it to hook into when you are only bolting a bullet onto the front of each line.

Large lists stay smooth. Past 5,000 lines the sorting operations hand off to a background Web Worker instead of running on the page's main thread, so the tab keeps responding while a very large list sorts rather than freezing until it finishes.

Why "Item 10" Comes Before "Item 2"

Not a bug. A-Z compares character by character, and the character 1 is lower than the character 2. Click 1-9 instead and the numbers sort as numbers.

A-Z gives you
Item 1
Item 10
Item 2
Item 9
1-9 gives you
Item 1
Item 2
Item 9
Item 10

Paste Item 1, Item 2, Item 10, Item 9 and try both buttons yourself. A-Z walks the two lines left to right and stops at the first character that differs. That happens at position five, where it is weighing the character 1 against the character 2, and it has no idea that the 1 is the front of a larger number. So everything starting with "Item 1" sorts ahead of "Item 2", including "Item 19" and "Item 100" if your list had them. This is called lexicographic sorting, or dictionary sorting, and it is what string comparison does in every programming language unless you specifically ask for something else.

The 1-9 button asks for something else. It uses a numeric-aware comparison that spots a run of digits inside a line and treats it as a single value, so it reads "10" as ten rather than as a 1 followed by a 0. That is usually called natural sorting, because it matches how a person reads a number embedded in text instead of how a computer reads raw characters.

The distinction bites hardest on anything with numbering baked into the text: chapter lists, invoice numbers, photos straight off a camera or a scanner, versioned drafts like "Draft v9" and "Draft v10", or product SKUs. Those are exactly the lists where a wrong sort looks right at a glance and only falls apart when someone works down the page in order.

When it does not matter: if your list is purely alphabetic with no digits in it, A-Z and 1-9 return identical output, because there are no digit runs for the numeric comparison to treat any differently. The two buttons only diverge once numbers show up inside the lines.

Accented Letters Sort Where You Expect Them To

An accent does not exile a word to the bottom of the list. café sorts next to cafe and cage, where its base letter belongs.

This tool
café
cage
Müller
Zebra
A raw byte sort
Müller
Zebra
café
cage

Sorting text with accented letters in it raises a question plain ASCII never has to answer: where does é belong relative to e? A-Z and Z-A answer it with your browser's locale-aware string comparison rather than by comparing raw character codes, and the two columns above show why that choice matters.

Compare by raw code point, the way a byte-oriented sort or a quick shell one-liner does, and every accented letter lands after every unaccented one, because accented characters simply sit higher up the Unicode table. That is how Zebra ends up ahead of café: capital Z's code point is lower than the code point for é. No human alphabetizes a list that way.

Locale-aware comparison treats an accented letter as a variant of its base letter for ordering purposes instead, which is the behavior almost everyone actually wants from a general-purpose sorter. It matches how alphabetized lists work in French, Spanish, German, Portuguese and the rest of the languages built on accented Latin letters. A mixed list of names such as McCarthy, mcdonald and Müller comes out in normal reading order with no cleanup first.

One caveat worth knowing: the exact placement of a specific accented letter can shift with the language rules your browser applies, since languages disagree about where letters like ü or ø sit relative to their unaccented neighbors. For everyday lists of names, addresses, product titles and cities this default is right without any configuration. If you are sorting against one particular language's dictionary convention, spot-check the output rather than assuming a universal answer.

Case Sensitivity: Sorting and Deduplicating Disagree on Purpose

Sorting groups the case variants together. Deduplicating collapses them into one. Neither has a toggle on this page.

A-Z alone
apple
Apple
APPLE
banana
A-Z plus Remove duplicates
apple
banana

A-Z, Z-A, 1-9 and Length all share the locale-aware comparison described above, and it is case-aware without being case-segregating. It keeps a word next to its capitalized twin instead of splitting the list into an uppercase block and a lowercase block the way a raw character-code sort would. So apple, Apple and APPLE land together, though the order among those three variants is the comparison's call rather than something you set. There is no "ignore case" switch for the sort buttons themselves.

The Remove duplicates checkbox deliberately plays by different rules. It lowercases every line before checking it against what it has already kept, so those same three spellings count as one entry and only the first survives. That comparison always ignores case, and nothing on this page changes that.

Need Apple and apple kept as two separate entries? This checkbox cannot do it. Use the dedicated Remove Duplicates tool instead, where the main Remove Duplicates button is case-sensitive by default and a separate Ignore Case button handles the other behavior, so you pick which one you want per run.

One more pair worth separating, since both sound like they produce backwards output: Z-A re-sorts the list into descending alphabetical order no matter what order it was in when you clicked. Reverse sorts nothing at all. It takes whatever order the lines are in right now and flips it top to bottom, so reversing an unsorted list does not alphabetize it in either direction. It just puts the last line first.

Numbers, Blank Lines and Invisible Spaces

Plain numbers still sort as text under A-Z. Blank lines disappear. Leading spaces do not, and they will wreck your order.

A-Z on 9, 10, 2, 21
10
2
21
9
1-9 on the same list
2
9
10
21

Every sorting operation here treats a line as a string first and as a number only when you explicitly ask by clicking 1-9. Feed a list of bare numbers to A-Z and you get the left column above, because 1 is a lower character than 2 and 2 is lower than 9, whatever digits follow. That is correct behavior for a general-purpose text sorter, and it is the whole reason 1-9 exists as a separate button.

Blank lines are dealt with before any comparison happens. A line that is empty, or holds only spaces and tabs, is filtered out of the working list entirely. It is not sorted to the top, not pushed to the bottom, not held in place. If your pasted list uses blank lines as visual spacing between entries, expect that spacing to be gone once you sort, because the tool never saw those lines as content in the first place.

The one that catches people: a line with visible content is not trimmed before comparison. Paste from a PDF or a table cell and you can easily pick up an invisible leading space, which then counts as that line's first character. Whitespace sorts below letters and digits, so the line jumps toward the top of an A-Z sort even though its visible text belongs in the middle of the alphabet. If a sorted list comes out in an order you cannot explain from the text you can see, a stray leading space is the first thing to check.

What Happens to Ties, and When Duplicates Get Dropped

Identical lines keep their original order, and Remove duplicates runs after the sort, never before. That second part decides which copy survives.

A-Z, duplicates on
Keeps the
alphabetically
first copy
Shuffle, duplicates on
Keeps a
random
copy

A sort is called stable when two entries the comparison considers equal keep their original relative order instead of being scrambled. Since 2019 the JavaScript language specification has required the built-in array sort to be stable, and every current browser engine implements that, so A-Z, Z-A and 1-9 all preserve the original order of lines that compare as exactly equal. In practice that shows up with genuinely identical lines: three copies of Follow up with client scattered through a list stay in their original relative order rather than swapping around.

Length sorting does not lean on that guarantee at all. It carries an explicit tiebreaker: when two lines have the same character count, they are compared alphabetically instead of being left wherever the algorithm dropped them. So a length sort is fully predictable and repeatable even on a list stuffed with same-length lines.

The ordering of operations is the part worth remembering. Click A-Z with Remove duplicates checked and the tool sorts the whole list first, then walks the sorted result dropping any line whose lowercase form it has already seen. The survivor is therefore the alphabetically first occurrence. Click Shuffle with the same checkbox on and deduplication runs against the freshly randomized order instead, so which copy of a repeated line survives is effectively random rather than tied to where it sat in your pasted text. If you care about which occurrence you keep, sort before you deduplicate rather than shuffling.

Six Things People Actually Use This For

Alphabetizing a contact or guest list

Paste the names one per line and click A-Z. Locale-aware comparison handles mixed casing and accented names on its own, so a list mixing McCarthy, mcdonald and Müller comes out in sensible reading order with no manual cleanup first.

Fixing an exported list that numbered itself wrong

Exports carrying "Item 2" and "Item 10" need true numeric order, not dictionary order. Click 1-9 rather than A-Z and the list lands the way a human would expect. This is the single most common reason a sorted list looks subtly wrong.

Picking a winner, or a fair running order

Paste the entries, raffle tickets or names and click Shuffle. The Fisher-Yates shuffle backed by your browser's cryptographic random number generator produces a genuinely unbiased permutation, which matters when the result has to hold up as fair and not merely look randomized.

Turning a rough list into a numbered script

Get the lines into the order you want, then click 123 to add sequential numbering. Click it again on an already-numbered list to strip the numbers back off, which you will want before re-sorting, since the numbers would otherwise become part of what gets compared.

Flipping an order without re-sorting it

When a list is already in the right order but running the wrong way, newest entry last instead of first, Reverse flips it without touching the ordering logic underneath. That is a genuinely different operation from clicking Z-A on an A-Z list, even though both can look "backwards" in specific cases.

Handling ten thousand lines

Everything above behaves identically at ten lines and at ten thousand. Past 5,000 lines the sort moves to a background thread so the page stays responsive, and the whole process still runs locally inside your browser with nothing uploaded to a server.

Frequently Asked Questions

Why does "Item 10" come before "Item 2" when I click A-Z?
A-Z and Z-A compare lines as plain text, character by character, the same way a dictionary orders words. At the point where the two lines differ, the character "1" is lower than the character "2", so anything beginning "Item 1" sorts before "Item 2" no matter what digits follow. Click the "1-9" button instead if you want the tool to read the number as a value rather than as individual characters.
What does the "1-9" natural sort button do differently from A-Z?
It uses a numeric-aware comparison that recognizes a run of digits inside a line as a whole number, so "Item 2" correctly sorts before "Item 10" instead of being sorted as if "1" were simply a smaller character than "2". This is usually called natural sorting, and it matters for anything with embedded numbering, like chapters, invoices, versioned file names, or SKUs.
Does sorting handle accented letters like café or Müller correctly?
Yes. The tool uses your browser's locale-aware string comparison rather than raw character-code order, so accented letters sort next to their unaccented base letter instead of being pushed to the end of the list the way a byte-level comparison would place them. That keeps a mixed list of accented and unaccented names in a normal, readable alphabetical order.
Is A-Z sorting case-sensitive?
It is case-aware but not case-segregating: "apple", "Apple", and "APPLE" land next to each other rather than being split into separate uppercase and lowercase blocks, which is how a raw character-code sort would treat them. There is no toggle to change this behavior for the sort buttons themselves; if you need explicit control over case sensitivity, that control lives on the Remove Duplicates tool's dedicated checkbox instead.
How does the "Remove duplicates" checkbox interact with sorting?
When checked, it runs after whichever button you clicked, not before, so with A-Z it deduplicates the already-sorted list and keeps the alphabetically first occurrence of each line. The comparison it uses is always case-insensitive, treating "Apple" and "apple" as duplicates, and it only applies to the six sorting and reordering buttons, not to Prefix, Suffix, or the numbering button.
What is the difference between "Reverse" and "Z-A"?
Z-A re-sorts your list into descending alphabetical order regardless of the order it was in before. Reverse does not sort anything at all; it takes whatever order the lines are currently in and flips it top to bottom, so reversing an unsorted list does not alphabetize it in either direction.
Does the tool remove or reorder blank lines when I sort?
Blank and whitespace-only lines are dropped from the list entirely before any sorting comparison happens, rather than being moved to the top, the bottom, or left in place. If your original text used blank lines purely for visual spacing between entries, expect that spacing to disappear once you run any sort or reorder operation.
Will a line with a leading space sort where I expect it to?
Not necessarily. Lines are only checked for whether they are entirely blank; a line that has visible content plus a stray leading space is not trimmed before comparison, so that space counts as the line's first character. Since whitespace generally sorts lower than letters, a line with an accidental leading space tends to jump toward the top of an A-Z sort even though its visible text would normally place it elsewhere.
If two lines are identical, does sorting keep them in their original order?
Yes. Modern JavaScript engines are required by the language specification to use a stable sorting algorithm, meaning entries that compare as equal keep their original relative order rather than being shuffled. Length sorting goes further and uses an explicit alphabetical tiebreaker for lines of equal length, so its output is fully predictable rather than depending on that underlying stability guarantee.
How much text can I sort, and is my data private?
There is no hard limit built into the tool; lists under a few thousand lines sort instantly, and lists over 5,000 lines are automatically handed off to a background Web Worker so the browser tab stays responsive during the operation. Everything runs as JavaScript inside your own browser, so nothing you paste is ever uploaded to a server or stored anywhere outside your device.

Related Text Tools

🔒 100% Private & Secure

All sorting and formatting happens locally in your browser - your text is never uploaded to any server.