Sort Lines Numerically Tool
Paste lines of text to sort them by their leading numeric value.
Result
How it is calculated
Each non-empty line is given a sort key: the tool trims the line, removes any leading characters that cannot be part of a number (anything except digits, e, E, ., +, -), and reads a decimal number from what is left. Lines are then sorted ascending by that value, and blank lines are dropped. Lines with equal values keep their original order. A line with no readable number gets the value 0 and so lands among the zeros. Only a dot works as the decimal point, and a thousands comma ends the number, so 1,000 counts as 1. The count shows how many lines were sorted. There is no descending option, so reverse the output yourself if you need it.
Worked example
You paste five response times, each starting with a number: 250, 42, 1200, -8 and 7.5. A plain alphabetical sort would put 1200 first and 7.5 near the end. The tool reads the leading numbers instead and orders them -8, 7.5, 42, 250, 1200. The negative value comes first because it is the smallest. The output is the five full lines in that order (the label after each number travels with it), and the line count shown is 5.
Common mistakes
- Putting words before the number. Leading letters are skipped, but the skipping stops at the first
eorE, soitem 10andline 3are read as 0 and are not sorted by their number, whilev10orid: 5work. - Using a decimal comma or a thousands separator.
7,5is read as 7 and1,000as 1; write 7.5 and 1000. - Expecting a number in the middle or at the end of the line to count. Only the number at the start of the line (after any skipped prefix) is used.
- Expecting a descending order, or sorting by a second column. Only ascending order by the first number is offered.
- Expecting blank lines to be preserved. Empty lines are removed, which also lowers the count compared with the lines you pasted.
About this calculator
This tool sorts pasted lines of text in ascending order by the number each line starts with, rather than treating the line as plain text. That distinction matters because ordinary alphabetical sorting compares characters left to right, so "100" sorts before "9" — a numeric sort instead compares the actual magnitude of the leading number, putting 9 before 100 as expected.
It's built for exactly the kind of data that trips up plain sort commands: server logs with numeric prefixes, exported spreadsheet rows, measurement readings, or any list where the meaningful order is numeric rather than lexicographic. Paste in the lines, get back a correctly ordered list, and copy the result with one click.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
No calculators found
Comments (0)