Text
Text Sorter
Sort a pasted list from A to Z or Z to A, with case folding and trimmed lines ready to go. Turn on natural numbers so item2 comes before item10, then copy it.
Sorted output
—
Output actions
Ready to copy output once your result appears.
A to Z by default, natural numbers only when asked
Text Sorter splits the box on line breaks and sorts those lines. A → Z is selected on arrival. Case insensitive and Trim whitespace start checked. Natural-number sorting starts unchecked, so the sample's item10 sorts before item2. Z → A reverses the sorted list, including lines that compared equal. Duplicate lines stay. Blank lines stay. Copy output copies the lines, and Download output saves text-sorter.txt.
How to sort the lines
- 1Paste into Lines to sort, or press Load sample. The sample is item10, item2, and Item1 on three lines. Reset clears the box and Sorted output.
- 2Leave A → Z, Case insensitive, and Trim whitespace as they are, or change them. Check Natural-number sorting only when item2 should precede item10. The controls do not sort until you click.
- 3Press Sort. Sorted output is the reordered lines. Copy output copies them. Download output saves text-sorter.txt. Sort never shows an error. An empty box sorts to an empty result.
What it is good for
- • Ordering the load sample as Item1, then item10, then item2, with the boxes in their initial state.
- • Putting item2 before item10 by checking Natural-number sorting and sorting again.
- • Keeping duplicate lines and blank lines in the list instead of dropping them.
Example
Input
item10 item2 Item1
Output
Item1 item10 item2
Load sample, then Sort, with the initial controls. Case folding makes Item1 the first line. Natural-number sorting is off, so item10 precedes item2. Check that box and Sort again to get Item1, item2, item10.
How two lines are compared
Sort splits on \n or \r\n, optionally trims each line, then sorts a copy. With Natural-number sorting off, the comparison is the ordinary < and > of JavaScript strings. If Case insensitive is checked, both sides are lowercased first. The original spelling is what gets printed. Item1 stays Item1 even though it was compared as item1. This order is code-unit order, not a dictionary. "10" is before "2" because the character 1 is before the character 2. é is after e, not beside it.
With Natural-number sorting on, the comparison is localeCompare for the English locale, with numeric turned on. Case insensitive uses sensitivity base. Case sensitive uses sensitivity variant. Numeric comparison is why item2 precedes item10, and why the bare lines 2 and 10 sort as two then ten. Lines that the numeric compare treats as equal keep their incoming order, because the sort is stable. item02 and item2 compare equal in this mode, so the one that appeared first stays first under A → Z. é and e also compare equal under base sensitivity, which is the case-insensitive natural mode. They do not compare equal in the default code-unit sort.
Direction and the three checkboxes
A → Z and Z → A are a button pair. A → Z starts pressed. Z → A sorts with the current comparison and then reverses the whole array. A reversal also flips ties. Two lines that compared equal, and therefore kept their original order under A → Z, come out in the opposite order under Z → A. The spelling of each line is still unchanged.
Case insensitive and Trim whitespace start checked. Natural-number sorting starts unchecked and sits on its own row. Trim removes the spaces at the two ends of a line and does not remove a blank line. A line that was only spaces becomes an empty line and then sorts with the other empty lines. None of these controls rerun the sort. Load sample only fills the box. Reset clears the box and the pane. Sort is the click that writes Sorted output. There is no status sentence for a successful sort.
When a sorted list is the list you wanted
Use this page when the lines are already one item each and the destination wants alphabetical order or numeric order. It does not remove duplicates. Repeated lines stay, next to each other after the sort if they compared equal. The text deduplicator drops repeated lines and can keep the first spelling. The pasted-list guide walks through that choice, and through when sorting is the wrong move because the original order mattered.
Wrapped lines are not joined here. Line operations can join breaks before you paste the result back. A shuffled order is a different button: the list shuffler reorders with a random draw and does not sort. This page has no random mode. A header row and a quoted CSV record are not special. Each physical line is one sort key, so a record that contains a line break is split.
Blanks, ties, and numbered labels
An empty line sorts before any line that still has a character, under A → Z, because the empty string is smaller. Under Z → A that empty line goes to the end, because the finished list is reversed. Trim whitespace does not delete it. There is no separate control that drops blanks. An empty box is one empty piece, and the joined result is empty.
Numbered labels need the natural checkbox. Left off, item10, item2, and Item1 become Item1, item10, item2. Turned on, they become Item1, item2, item10. The same switch puts 2 before 10 and a2 before a10. It does not rewrite item02 into item2. Those two compare equal, so A → Z keeps whichever came first in the paste, and Z → A puts the later one first. Accented letters follow the same split: the default sort uses code units, and the natural case-insensitive sort uses English base sensitivity, which can treat é and e as equal. There is no locale menu. Copy output copies the pane. Download output saves text-sorter.txt.
Rules and limitations
A → Z, Case insensitive, and Trim whitespace start on. Natural-number sorting starts off and uses English localeCompare with numeric comparison. Z → A reverses the sorted lines, ties included. Spelling is kept. Duplicates and blank lines are kept.
The default comparison is code-unit order on the optionally lowercased line. Trim does not delete blank lines. Sort does not error. Download output saves text-sorter.txt. The controls do not sort by themselves.
Common problems
If item10 is above item2, Natural-number sorting was off. Check it and press Sort. Changing the box without sorting leaves the previous lines.
If two equal lines swapped when you chose Z → A, the reverse flipped a tie. A → Z had kept the earlier line first. Accented letters that look grouped only do that in the natural case-insensitive compare.
Frequently asked questions
Why does the sample put item10 before item2?
Natural-number sorting starts unchecked. The default compare sees the character 1 before the character 2. Check the box and press Sort to get item2 first.
Does Z → A change lines that compared equal?
Yes. The list is sorted, then reversed. A tie that kept its original order under A → Z is flipped under Z → A. The letters on each line are not rewritten.
Are duplicates or blank lines removed?
No. Both stay in the list. Trim whitespace can turn a line of spaces into a blank line, and that blank line still sorts. Remove duplicates on the deduplicator if you need them gone.
What does the download save?
text-sorter.txt, the same lines Copy output copies. The name does not change when you switch direction or turn natural numbers on.
Is my input uploaded or saved?
This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.
About this tool
Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.
Guides
- Clean a pasted list while preserving its order
Remove duplicate lines, choose matching rules and join wrapped text without accidentally sorting your list.
Next steps
Related tools
Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.
Remove Duplicate Lines
Remove duplicate lines while keeping the first copy in its original order.
Open Remove Duplicate LinesLine Operations
Sort, reverse, number, trim, or join lines from a pasted block.
Open Line OperationsList Shuffler
Shuffle lines with a Fisher-Yates pass from crypto.getRandomValues.
Open List ShufflerFind & Replace
Replace every plain-text or regular-expression match, optionally ignoring case.
Open Find & ReplaceTrust
Policies, contact, and answers
Clear pages for how Toolbench works, what we collect, and how to reach us.