A sorted list is easier to scan, easier to deduplicate, and easier to diff against another list. Sorting is also the quickest way to spot outliers — the shortest and longest entries, or values far outside the expected numeric range, end up at the ends.
How to use the Sort Lines
- Paste your list, one item per line
- Choose a sort: alphabetical, reverse, numeric or by length
- Copy the sorted result
Alphabetical is not the same as numeric
Sorting numbers alphabetically produces the classic wrong answer:
1
10
100
2
20
3This is correct alphabetical order — character by character, '1' sorts before '2', so anything starting with 1 comes first regardless of magnitude. Numeric sort reads each line as a number and orders by value, giving 1, 2, 3, 10, 20, 100.
Use numeric sort for anything measured: prices, IDs, counts, version parts, timestamps.
Sorting by length
Less obvious but genuinely useful. Sorting by line length surfaces the extremes immediately — the truncated entries, the one row with a pasted paragraph in it, the keyword that is far longer than the rest.
It is a fast way to sanity-check exported data before importing it somewhere that enforces field limits.
Sorting data that is not plain words
Alphabetical order compares character by character, which produces correct text ordering and surprising results on anything else.
Dates sort correctly only in ISO format. 2026-03-09 sorts properly against 2026-11-15; 09/03/2026 and 15/11/2026 sort by day first and produce nonsense. This is one of the strongest arguments for ISO 8601 in any data you expect to sort.
Version numbers break the same way: 1.10.0 sorts before 1.9.0 because 1 precedes 9. Proper version ordering compares each numeric component separately, which plain alphabetical sorting cannot do.
IP addresses have the same problem — 10.0.0.9 before 10.0.0.10 only if the octets are padded.
Mixed case sorts by character code in a strict sort, which puts every capital before every lowercase letter: Zebra before apple. A case-insensitive sort is usually what people want.
The general fix for numeric-ish data is zero-padding: item002 and item010 sort alphabetically into the right numeric order.
Sorting as a way to find problems
Sorting is worth doing even when the order does not matter, because it drags related lines together and makes several classes of error visible at a glance.
Near-duplicates become adjacent. john@example.com and John@example.com end up next to each other, where before they were a thousand lines apart. The same applies to typos — Manchester and Manchestor land side by side.
Outliers move to the ends. A sorted list of product codes puts anything malformed at the top or bottom: the blank entry, the one with a leading space, the one that starts with a quote mark. Scanning the first and last ten lines of a sorted list catches most data quality problems in seconds.
Gaps become visible in sequential identifiers, which is hard to see in unsorted data.
For this use, sort a copy rather than the original if the original order carries meaning — chronological logs, ranked results, or anything where position is the data.
Sorting with a stable order
A sort is stable when items that compare equal keep their original relative order. It matters more often than it sounds.
Suppose you sort a list of names by surname, and two people share one. A stable sort leaves them in the order they arrived; an unstable one may swap them arbitrarily, and running the same sort twice can produce different output.
Stability is what makes multi-key sorting work with a simple tool. To sort by department and then by name within each department, sort by name first, then sort by department. Because the second sort is stable, the name ordering survives inside each group. Doing it in the other order does not work.
JavaScript's Array.prototype.sort has been required to be stable since ES2019, and all current browsers comply, so sorting in the browser behaves predictably.
One related gotcha: sorting a list where some lines are empty puts the blanks together at one end, which is usually convenient. If blank lines are separating sections and carry meaning, sorting destroys that structure, and there is no way to recover it from the output.
Frequently asked questions
Why are my numbers in the wrong order?
You are using alphabetical sort on numeric data. Alphabetically, 10 comes before 2 because the character '1' precedes '2'. Switch to numeric sort.
How are uppercase and lowercase handled?
Sorting uses locale-aware comparison, so 'apple' and 'Apple' sort adjacently rather than uppercase letters all sorting before lowercase as they would in raw ASCII order.
Does sorting remove duplicates?
No, duplicates are kept and end up adjacent. Use the Remove Duplicate Lines tool first if you want them gone.
Are blank lines preserved?
Blank lines are treated as empty entries and group together. Remove them beforehand if they are not meaningful data.