Sort Lines
Sort text lines alphabetically with options for descending order, unique lines, and case sensitivity. This sort lines tool is useful for keywords, names, and copied lists.
Whether you call it sort lines or sort text lines, this free tool handles it instantly in your browser.
Options
Example usage
Example input
banana apple banana
Example output
apple banana
Batch Processing
Enter multiple inputs, one per line. Each line will be processed separately.
More like this
Discover related tools and step-by-step guides for this kind of task.
How it works
- Paste line-based text into the input field.
- The tool sorts each non-empty line in ascending or descending order.
- Optional unique and case-sensitive modes help you control how lines are compared.
Use cases
Sorting is more opinionated than it looks
A computer sorting "by default" uses character codes, where every uppercase letter sorts before every lowercase one — so Zebra lands before apple. That is almost never what a human wants, which is why sorting tools have to make a deliberate choice about case. Numbers are the other classic surprise: sorted as text, 10 comes before 2, because the comparison happens character by character and "1" is less than "2".
The workaround for numbers is zero-padding (01, 02, 10), which makes text order match numeric order. It is the same reason well-named files use 2026-07-04 rather than 4-7-2026: the ISO date format is designed so that alphabetical order and chronological order are the same thing.
Sort, dedupe, or alphabetize?
This tool sorts lines with control over direction, uniqueness, and case — the general-purpose option for lists and code. If your goal is specifically dictionary-style A–Z or Z–A ordering of words and names, our Alphabetical Order tool is tuned for that and explains reverse alphabetical order along the way. If you only want repeats gone while keeping the original order, Remove Duplicate Lines does that without touching sequence.
A note on the unique option: sorting groups identical lines together, which makes duplicates trivial to spot and remove in one pass. That is why "sort and dedupe" is the traditional pairing in command-line work — the sort is what makes the deduplication cheap.
Natural order, shuffling, and picking at random
A plain string sort puts item10 before item2, because it compares character by character and 1 sorts before 2. That is correct by the letter and almost never what anyone wants from a list. Natural ordering, on by default here, reads runs of digits as numbers so item2 comes first. Turn it off when you need a strict character-by-character sort, for example when checking that a file matches another tool’s output exactly.
Shuffling is the inverse operation and uses a Fisher-Yates shuffle, which produces every permutation with equal probability. The naive alternative, sorting by a random comparator, is subtly biased and favours arrangements close to the original. If you are randomising a question order, a team draw or a test fixture, that difference matters more than it sounds.
Picking one item at random is a shuffle you only need the first element of, and it is worth a separate mode because the common uses are different: choosing a winner from a list of entries, picking a reviewer, selecting a sample row. The count of how many items were in the pool is shown alongside, which is the number you want when the draw has to be defensible.
Cleanup
Explore all text cleanup tools
Browse every tool for this kind of task, along with helpful guides that show you how to get the most out of them.
Related tools
Supporting guides
Conversion History
Loading...
FAQ
Can I sort lines in reverse order?
Yes. Turn on the descending option to reverse the sort order.
Does unique mode remove duplicate lines?
Yes. It keeps only the first matching version of each line before sorting.
Are blank lines included?
No. Empty lines are skipped so the sorted output stays clean.

