Sort Lines Alphabetically
Free line sorter. Sort any text by lines alphabetically, reverse-alphabetically, by length, or numerically — with optional case-insensitive comparison.
Quick answer
Default sort is alphabetical (A-Z), case-sensitive — uppercase letters sort before lowercase. Reverse-alphabetical reverses the order. Numeric sort handles lines that start with numbers naturally (1, 2, 10 instead of 1, 10, 2). All sorts are stable.
Sort Lines Alphabetically
How it works
Splits on line breaks, sorts each line according to the selected order, and rejoins. Numeric sort interprets each line as a number; length sort orders by character count.
When to use it
Organizing lists, prepping data for review, building clean ToCs, ordering tags or categories, or spotting outliers (sort by length to find lines that look weird).
Common mistakes
Using alphabetical sort on a list of numbers — "10" comes before "2" alphabetically. Switch to numeric sort for any list of numbers.
How line sorting works
The default ASCII sort orders lines by their first character's code point, then by the second, and so on. This means uppercase letters (codes 65-90) sort before lowercase letters (97-122) — 'Zebra' comes before 'apple' in default mode. Case-insensitive mode normalizes everything to one case before comparing. Numeric sort detects leading numbers and sorts by value rather than character — '10' comes after '2' instead of after '1'. Reverse mode just flips the comparison.
When to use it
Alphabetizing lists for documentation or readability. Sorting contact names, file names, or directory listings. Preparing data for binary search or merge operations. Sorting tag lists or keyword lists for SEO research. Putting bibliographies in author-alphabetical order.
Common mistakes
- Default sort surprises with mixed case. 'Banana' before 'apple' is correct ASCII but rarely what you want. Use case-insensitive mode for 'human-readable' alphabetical order.
- Numeric data in default-sort mode. Sorting '1', '10', '2' alphabetically produces '1', '10', '2'. Use numeric sort for any numbered list.
- Locale differences. ASCII sort doesn't handle accents the way most locales expect (é, ñ, ü). For locale-aware sorting, use a language-specific tool — this calculator uses standard JavaScript string comparison.
Frequently asked questions
How do you sort text alphabetically?
Paste the lines into the tool above and pick the sort direction (A-Z or Z-A). Toggle case-insensitive for 'human' alphabetical order, or numeric sort if your lines start with numbers.
Why is uppercase sorted before lowercase?
Default sort uses ASCII/Unicode code points. Capital letters have lower code points (A=65) than lowercase (a=97), so they sort first. Toggle case-insensitive to ignore the difference.
Can I sort lines by number?
Yes. Use numeric sort for lines that start with numbers — it sorts '1', '2', '10' in that order rather than the alphabetical '1', '10', '2'. Mixed text-and-number lines fall back to character order for non-numeric portions.