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 reads the first number anywhere in the line, such as the 12 in Item 12, the 3.5 in Price: 3.5 or the -4 in -4 x. A minus or plus sign counts only at the start of a word, so A-2 is read as 2. 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 number at all goes last, in its original order. 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
- Expecting a minus sign inside a word to count. A sign counts only at the start of a word, so
A-2is read as 2, not -2; put a space before the minus if you mean a negative number. - Using a decimal comma or a thousands separator.
7,5is read as 7 and1,000as 1; write 7.5 and 1000. - Expecting a later number in the line to count. Only the first number in each line is used, so
Dec 5 - 12 itemsis sorted by 5. - 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 first number in each line, 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.
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
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
For dependable results, make sure the number you want to sort by is the first number on each line. The tool takes the first number it finds, wherever it stands, so Item 12 sorts by 12, and lines with no number go to the bottom. Write 1000, not 1,000, since a comma ends the number. It sorts ascending only; for a descending list, read the output from the bottom. What do your lines look like?