Every numbered list that passes through a plain sort comes out the same wrong way: item 1, item 10, item 2, item 20, item 3. Chapters, procedure steps, files in a series, all scrambled in a pattern that looks random until you see its logic. It is not carelessness on the tool's part: the sorter did exactly what it was asked to do.
This guide explains why numbers end up in the wrong order, with the free Sort Lines Tool on Ovatly. Two features repair it: natural ordering in the alphabetical modes, which reads numbers inside text as numbers, and the numeric modes, which sort by the number each line starts with. It also covers mistakes that survive even good tools, like expecting a mid-line number to count.
Contents
- Quick answer
- The core mistake: text is compared digit by digit
- Fix one: natural ordering in A to Z
- Fix two: the numeric modes and the leading number rule
- Mistakes that remain: case, duplicates and expectations
- How to sort a numbered list correctly, step by step
- Worked example: item 10, item 2, item 1
- Limitations and alternatives
- Common mistakes
- FAQs
- Conclusion
Quick answer
Numbers go wrong because plain alphabetical sorting compares text one character at a time: it reads the 1 of item 10 before the 0, so item 10 wins against item 2. The fix is a sorter that understands numbers. In the Sort Lines Tool, A to Z sorting is natural, so item 1, item 2, item 10 comes out in the order you mean, and the numeric modes sort lines by the number at their start. Numeric modes only see a number at the very start of a line.
The core mistake: text is compared digit by digit
Alphabetical sorting was designed for words. It compares two lines character by character from the left, and the first difference decides the order. That works beautifully for words. For numbers written as text it breaks, because a number's size depends on all its digits together, not its first digit alone.
Walk through item 2 against item 10. The first five characters match exactly: i, t, e, m, space. At the sixth character, one line has 2 and the other has 1. Since 1 comes before 2, item 10 is placed first, and the comparison ends there. The 0 that makes ten into ten is never looked at. Scale it up and a list to item 100 comes out as 1, 10, 100, 11, 12, with every number starting with 1 bunched before 2 appears.
Nothing malfunctioned: the sorter applied word rules to number text. The fix has to change the rule, not the data. Renaming items to item 02 works around it, but it edits your text, and it breaks again when the list outgrows the padding.
Fix one: natural ordering in A to Z
Natural ordering keeps the character-by-character comparison for text, but when both lines have a run of digits at the same position, it compares those runs as whole numbers: 2 is smaller than 10 wherever they appear, so item 2 correctly comes before item 10. In this tool's alphabetical modes, sorting item 10, item 2, item 1 from A to Z gives item 1, item 2, item 10, with no padding, renaming or setup. The same behaviour helps anywhere numbers live inside labels: version 9 before version 10, chapter 3 before chapter 12.
Natural ordering pairs with one more rule worth knowing: alphabetical sorting here ignores case differences, so apple and Apple sit next to each other instead of splitting into a capital block and a lowercase block.
Fix two: the numeric modes and the leading number rule
Sometimes the number is not inside the label, it is the label: measurements, scores, prices, counts. For those, the tool offers numeric low to high and numeric high to low.
The rule is strict: the numeric modes read only the first number found at the start of each line. A line that begins with its number, like "5 apples", sorts by 5. A line like "apples 5" has no leading number and is placed last, whatever its 5 meant; all such lines go last together.
This is by design. A number buried in text is ambiguous: "apples 5 for 3 dollars" holds two numbers, and no honest way to know which you meant. The start of the line is the one position that is never ambiguous, so that is what the numeric modes read. If your numbers sit mid-line, either move the number to the front, or use A to Z, whose natural ordering handles numbers inside text.
Mistakes that remain: case, duplicates and expectations
Even with the right tool, two expectation mistakes keep causing confusion.
The first is expecting sorting to clean. Sorting reorders lines and does nothing else: duplicates stay duplicated, typos stay misspelled, and every line keeps its exact original text. If a sorted list still shows the same line twice, that is a duplicate: remove it first with Remove Duplicate Lines, then sort. A mid-line number likewise cannot drive a numeric sort: in numeric modes, only the leading number exists.
How to sort a numbered list correctly, step by step
- Open the Sort Lines Tool.
- Paste your list, one item per line.
- If the numbers sit inside labels, like item 2 and chapter 12, choose A to Z and let natural ordering handle them. If each line starts with its number, choose numeric low to high or numeric high to low.
- Read the sorted result below, checking the digit boundaries: 9 and 10, 99 and 100.
- Copy or download the sorted lines.
Worked example: item 10, item 2, item 1
Start with the input that breaks plain sorters:
item 10
item 2
item 1
A plain alphabetical sort returns item 1, item 10, item 2: the 1 of item 10 beats the 2 of item 2 at the first digit. Sorted A to Z in this tool, the same input gives:
item 1
item 2
item 10
The numbers inside the text are compared as numbers, not as single digits, so the order matches what a person means.
Now the numeric version. Given lines "12 oranges", "5 apples", "3 pears" and "bananas", numeric low to high returns "3 pears", "5 apples", "12 oranges", then "bananas" last, because it has no leading number. Add "apples 5" and it joins "bananas" at the end: its 5 sits mid-line, where numeric modes cannot see it.
Limitations and alternatives
Natural ordering fixes numbers inside text, and the numeric modes fix numbers at the start of a line, but neither reads meaning. A list mixing the two shapes will sort its numbered lines among themselves and park the rest last in numeric mode; mixed lists usually sort best A to Z, where natural ordering keeps every embedded number honest.
The tool also stays in its lane: it does not remove duplicates, does not edit line contents, and offers only its seven modes: A to Z, Z to A, numeric low to high, numeric high to low, shortest first, longest first, and reverse order. For lists keyed by line size rather than numbers, the length modes are the right alternative, and the wider Text and Writing Tools guide archive covers the cleaning and deduplication steps before sorting.
Common mistakes
- Padding numbers to please a plain sorter. Renaming item 2 to item 02 works until the list outgrows the padding. A naturally ordered sort makes the workaround unnecessary.
- Expecting numeric modes to find mid-line numbers. Only a number at the very start of the line counts; lines without one sort last.
- Sorting before deduplicating. Repeated lines stay repeated. Remove duplicates first, then sort.
- Checking the wrong boundary. A sort can look right for items 1 to 9 and still be wrong at 10; check where digit counts change.
- Assuming the sorter changed your text. Only the order changes; if a line looks different, it was pasted that way.
FAQs
Why does plain sorting put item 10 before item 2? Plain alphabetical sorting compares character by character. Both lines share item and a space, then 1 is compared with 2, and 1 wins, so item 10 is placed first without the rest of the number ever being considered.
How are lines with numbers in the middle handled in numeric mode? Only a number at the very start of the line counts. A line like apples 5 has no leading number and sorts last in numeric modes.
Can it remove duplicates while sorting? Not directly. Run the list through Remove Duplicate Lines first, then sort the cleaned result here.
Does sorting change the lines themselves? No. Only the order changes; every line keeps its exact original text.
Is my list uploaded? No. Sorting happens in your browser on your device.
Conclusion
Numbers end up in the wrong order because word rules were applied to number text: first digit wins, item 10 beats item 2. The repair is a sorter with better rules, and the Sort Lines Tool carries both: natural ordering inside A to Z for numbers embedded in labels, and numeric modes that read the number each line starts with. Keep numbers leading for numeric order, dedupe first, and check the 9-to-10 boundary. For arranging a list by size instead, read the companion guide: How to Sort a List by Length Instead of Alphabet.