Sort Lines
Sort lines alphabetically, numerically, by length or in reverse order. The sorted list appears live as you paste, so alphabetizing names, ordering numbers by value or flipping a list takes seconds. A case-sensitive switch matches the stricter order that databases and programming languages use.
Sort Lines tool
How to use it
- Paste your lines into the box.
- Choose a sort order, alphabetical, numeric, by length or reverse.
- Copy the sorted result.
What is a text sorter?
A text sorter reorders the lines of a list by a rule you pick. This tool can sort lines alphabetically, by numeric value, by length, or simply reverse the current order.
A to Z: compare lines with language-aware rules, case ignored
Numeric: compare the number each line starts with (parseFloat)
Length: compare character counts; Reverse: flip the list
Alphabetical mode uses your browser's language rules, so an accented letter sorts beside its plain twin instead of after z. Numeric mode reads the value at the start of each line, which is what puts 2 ahead of 10. Blank lines are dropped in every mode, and lines are moved whole, never edited.
Worked example
How one list orders under each mode
Take the four lines 10, 2, apple and Zebra. Here is how the tool sorts lines under each mode.
| Mode | Result | Why |
|---|---|---|
| Alphabetical A to Z | 10, 2, apple, Zebra | Digits sort before letters, character by character, so 10 beats 2; case is ignored |
| Alphabetical, case-sensitive | 10, 2, Zebra, apple | Raw character codes put every capital before any lowercase letter |
| Numeric 0 to 9 | 2, 10, then the words | Values are compared as numbers; keep word lines out of a numeric sort |
| By length | 2, 10, apple, Zebra | 1, 2, 5 and 5 characters; equal lengths keep their original order |
| Reverse current order | Zebra, apple, 2, 10 | No sorting at all, the list is flipped top to bottom |
Sorting options explained
Alphabetical sorting puts lines in dictionary order using your browser's language rules, so accented letters sort next to their plain versions (é beside e) instead of being dumped at the end the way a raw byte sort would do. By default case is ignored, so Apple and apple sit together. Turn on ‘Case-sensitive’ to sort by raw character code instead, which puts every line that starts with a capital ahead of the lowercase ones (Zebra before apple), the order most programming languages and databases use.
Numbers
Numeric sort reads the number at the start of each line and orders by value, so 2 comes before 10 and 3.5 lands between 3 and 4. A plain alphabetical sort compares character by character and puts 10, 100 and 1000 ahead of 2, which is the classic problem with file names and invoice numbers. Lines that do not begin with a digit have no value to compare, so keep those out of a numeric sort. Prices work only if you remove the currency sign first, since ‘$12’ starts with a symbol rather than a number.
Length and reverse
Sorting by length orders lines from shortest to longest by character count, which is handy for headlines, meta descriptions, or a set of options that must fit a menu. Lines of equal length keep their original order. ‘Reverse current order’ does not sort at all; it just flips the list top to bottom, which turns an A to Z list into Z to A or undoes a paste that arrived backwards.
Blank lines are dropped in every mode. Leading spaces are not trimmed, so a line that starts with a space sorts ahead of the letters; run the list through the remove extra spaces tool first if the indentation was accidental.
Common uses
- Alphabetizing names and word lists
- Ordering numbers correctly by value
- Sorting rows before importing to a spreadsheet
- Reversing the order of a list
- Putting a bibliography or glossary in order
- Sorting file names or version numbers by value
When to use it
- You want to sort lines A to Z to alphabetize a list of names online without pasting it into a spreadsheet first.
- File or invoice numbers keep sorting as 1, 10, 2 and you need them in true numeric order.
- You need to sort lines alphabetically to put a bibliography or glossary in order before handing it in.
- A chat log or changelog arrived newest-first and you want it flipped back to chronological order.
- A set of headlines should be reviewed shortest to longest to see which fit a menu.
Related tools
Remove Duplicate Lines comes first when the list has repeats; dedupe it there, then sort lines here in any order you need.
Reverse Text flips characters and words, not just whole lines, when the text itself should read backwards.
Remove Extra Spaces trims accidental leading spaces that would otherwise make a line sort ahead of every letter.