Sort Lines
Sort lines alphabetically, numerically, or in reverse.
Use on any page (bookmarklet)
Want Sort Lines without leaving the page you're on? Drag the button below to your bookmarks bar, then click it on any website to open Sort Lines right there — it runs entirely in your browser.
Use responsibly: a bookmarklet runs on whatever page you click it on. Avoid sensitive sites such as online banking, payment, or healthcare pages — you run it at your own risk. Everything is processed locally and no data is sent anywhere. See our Terms.
- Show your bookmarks bar if it's hidden — Ctrl+Shift+B (⌘+Shift+B on Mac).
- Drag the button above onto the bookmarks bar.
- Open any website and click the bookmark — the Sort Lines panel appears in the top-right corner. Use ✛ to move it between corners, or ›/‹ to tuck it against the edge and pull it back out.
- Click the bookmark again (or the ✕) to close it.
Note: a few sites with strict security policies may block bookmarklets.
Examples
Alphabetical (A to Z)
Input
banana apple cherry
Output
apple banana cherry
Numeric
Input
10 2 1
Output
1 2 10
About this tool
This free online tool sorts lines of text alphabetically, numerically, or in reverse. Paste a list of names, words, numbers, or any line-separated data and get it back sorted, with options for descending order, true numeric ordering, and case-insensitive comparison. Everything runs in your browser with no upload.
How to use
- Paste your lines into the input box (or click Sample to try it).
- Pick options: Z to A for descending, Numeric for number values, Ignore case to fold capitals.
- Copy the sorted result from the output box.
Why sorted output sometimes looks wrong
A default sort is lexicographic: it walks the string one character at a time and compares character codes. That produces three results people rarely expect, and all three have the same cause.
- 10 before 2 — the comparison sees “1” against “2” and stops there. Switching on Numeric compares the values instead.
- Capitals before everything — uppercase letters hold lower character codes than lowercase, so Zebra precedes apple. Ignore case folds them together.
- Accented letters at the end — characters like é, ö and ß sit far above A–Z in the code table, so they land after Z rather than beside their base letter.
Leading spaces and blank lines
A line beginning with a space sorts before every visible character, which is why one stray indent can push an entry to the top and look like a bug. Blank lines behave the same way for the same reason — an empty string precedes everything. Sorting does not trim or clean anything, so if the input is ragged it is worth running remove empty lines first and stripping stray indentation before you sort.
Sorting is not deduplicating
Every line survives a sort, repeats included — the order changes and nothing else. What sorting does do is bring identical lines next to each other, which is usually how you spot duplicates at all. To remove them, pair this with remove duplicate lines; the order you run the two in makes no difference to the final set.
Common uses
Alphabetising name and word lists, ordering keyword sets before research, sorting numeric IDs and invoice numbers, tidying a CSV column pasted out of a spreadsheet, grouping log lines to see repeats, and putting any list into a predictable order before diffing it against another. For comparing two sorted lists afterwards, the text diff tool highlights what changed.
Frequently asked questions
Why does 10 sort before 2?
Because a plain alphabetical sort compares character by character, and the character "1" comes before "2" — it never sees the number as a whole. This is the single most common surprise when sorting lists, and it affects anything with digits: version numbers, invoice IDs, chapter names. Turn on Numeric to compare by value instead, so 2 lands before 10.
Why do all the capital letters sort to the top?
Sorting follows character codes, and in ASCII every uppercase letter has a lower code than every lowercase letter — so Zebra comes before apple. Turn on Ignore case to fold them together and get the ordering a human would expect.
How do accented and non-English characters sort?
By raw character code, which puts every accented letter after the entire plain A–Z range — so "Ångström" lands after "Zulu" rather than next to "Anderson". That is correct for byte ordering and wrong for most human purposes. If you need dictionary ordering for a specific language, sort in a tool that applies that language's collation rules, since correct placement genuinely differs between them.
Can it sort file names like file2, file10 correctly?
Turn on Numeric, which compares embedded numbers by value and handles the common file2 / file10 case. A traditional alphabetical sort puts file10 before file2, which is why file managers use their own "natural" ordering. If your names mix numbers in several positions, padding them with leading zeros beforehand gives the most predictable result.
Does sorting remove duplicates?
No — every line survives, repeats included. Sorting only changes order. It does make duplicates visible by grouping them together, which is often how you notice them in the first place; to actually drop them, run the remove duplicate lines tool before or after sorting.
Does it change the lines themselves?
No. Lines are reordered but their content is untouched — no trimming, no case changes, no normalisation. If leading spaces are throwing your sort off, strip them first, because a line starting with a space sorts before everything else.
What happens to blank lines?
They are treated as lines and sort to the top, since an empty string precedes every other value. Removing them first usually gives a cleaner result.
Is my text uploaded anywhere?
No. Sorting happens in your browser with no upload, so your data never leaves your device — which matters when the list is customer names or internal IDs.
Learn more
Related tools
Regex Tester
Test regular expressions with live match highlighting, groups, and replace.
Word Counter
Count words, characters, sentences, and reading time.
Case Converter
Convert text between upper, lower, title, camel, and snake case.
Character Counter
Count characters and stay under tweet, SMS, and meta tag limits — live.