Sort Lines
Alphabetical sorting.
Loading tool…
Sorting text, and why order is not obvious
Sorting a list of lines seems trivial until the details bite. Plain alphabetical sorting compares character codes, which puts all uppercase letters before all lowercase ones, so Zebra lands before apple unless the comparison is case-insensitive. Numbers sorted as text order by their first digit, putting 10 before 2 — natural sorting fixes this by comparing numeric runs as values.
Language adds more. Accented characters, Arabic script, and German umlauts each have locale-specific collation rules that a naive byte comparison ignores. Beyond ordering, the useful companions are reversing, removing duplicates, and shuffling — all operations on the same list, and all far quicker here than setting up a spreadsheet formula.
Why we built this tool
The common jobs are tidying a list of names, ordering imports or dependencies, alphabetising a glossary, sorting log lines, or preparing a list for comparison against another one — since two sorted lists diff cleanly and two unsorted lists do not.
Those lists are frequently email addresses, customer names, hostnames, or internal identifiers. Pasting them into an online sorter is a data transfer performed for the sake of an operation your browser can do in a millisecond. Ours sorts locally in JavaScript with no request made, no storage, and no line limit. It also works offline, which is worth something for a tool you use reflexively.
Tips and common mistakes
- Turn off case sensitivity for names and words, or every capitalised entry sorts before the lowercase ones.
- Use natural sorting for lists beginning with numbers, otherwise 10 comes before 2.
- Trailing whitespace changes sort position invisibly — clean the list first.
- Sorting both of two lists makes them far easier to compare afterwards.
Open Sort Lines with a link
Assistants and scripts can open Sort Lines with its input already in the link, after the #, which never leaves your device:
#text=— the text to work on
Example: https://mygadgets.ink/tools/sort-lines/#text=... · also compressed gz fields and ?url=. How tool links work
Quick start: using Sort Lines
- Paste your list into the input above, one item per line.
- Choose ascending or descending order.
- Set case sensitivity — usually you want it off for names and words.
- Enable numeric or natural sorting if the lines start with numbers.
- Copy the sorted result.
Clean the list first with Remove Duplicate Lines, then compare two versions using Diff Checker.
What sorting does
Sorting rearranges the lines of your text into order — A to Z, Z to A, or numerically. Each line is treated as an item, and the tool reorders them without changing their content. A tangled list becomes an orderly one in a click.
The options that matter
- Ascending vs. descending — A→Z or Z→A, smallest→largest or the reverse.
- Case sensitivity — whether "apple" and "Apple" sort together or apart. Case-sensitive sorting puts all capitalized items before lowercase ones, which is rarely what people want. Case-insensitive usually reads more naturally.
- Remove duplicates while sorting — many sorting tasks also want to collapse repeats, which pairs with Remove Duplicate Lines.
The number gotcha
The classic surprise: sorting numbers as text. Alphabetical sorting compares character by character, so 10 comes before 2 because "1" comes before "2". A list of 1, 2, 10, 21, 100 sorted as text becomes 1, 10, 100, 2, 21 — clearly wrong for numbers. If your lines are numeric, use a numeric sort option so values order by size, not by their first digit. This trips up nearly everyone at least once.
Where sorting helps
- Alphabetize a list of names, terms, or items.
- Organize data before pasting into a spreadsheet or document.
- Prepare a list for de-duplication.
- Make a reference list easy to scan.
Common uses
- Alphabetize any list.
- Order data for a spreadsheet.
- Tidy a jumbled list.
- Sort numerically by value.