Least to Greatest Calculator
Result
Sorted (least to greatest)
- Minimum
- -10
- Maximum
- 12.5
Arranging a set of numbers from least to greatest means putting them in the order they would sit on a number line, reading left to right. The list 7, −3, 12.5, 0, −10, 4 becomes −10, −3, 0, 4, 7, 12.5, and the two ends of that line are the smallest value and the largest. This page does that for any list you paste in, up to two hundred numbers, and reports the sorted list along with the minimum and the maximum. It is a small job and it is worth being careful about, because the obvious way to do it is wrong in two places. The first is that numbers must be compared as numbers, not as text. Sorting those same values as strings gives −10, −3, 0, 12.5, 4, 7 — it puts 12.5 before 4, because the character 1 comes before the character 4 and the comparison never gets as far as the digit after the point. On a list of single-digit positive numbers the error never appears, which is exactly what makes it dangerous: it survives every test that does not happen to include a multi-digit value or a negative one, and then shows up in production on a list that does. The second is negative numbers, where the same trap has a mirror: as strings, −10 sorts before −2, which looks right, while −2 sorts before −10, which is wrong. The correct order puts −20 before −10 before −3, because further left on the line means smaller, not longer. Two things the page does that are easy to miss. It keeps duplicates, so 5, 5, 3 comes out as 3, 5, 5 — removing repeats is a different operation, and doing it here would mean the answer no longer contains exactly the numbers you gave. And it prints each value in a canonical form, so 12.50 becomes 12.5 and +7 becomes 7, because trailing zeros and leading plus signs are not part of a value. If you typed them that way deliberately, the output will not preserve it. Sorting a list is the first step in most of the things people want from a set of numbers: the median is the middle of the sorted list, the range is its two ends, and quartiles are read off it at fixed positions.
Formula
7; −3; 12.5; 0; −10; 4 ⇒ −10, −3, 0, 4, 7, 12.5;最小 = −10,最大 = 12.5
- n
- How many numbers are in the list — between 1 and 200. One is allowed and gives a list of one, which is genuinely correct rather than a degenerate case: a single number is already in ascending order, and it is both the smallest and the largest of the set
- a ≤ b
- The comparison the sort rests on, and the whole of its correctness. It is a numeric comparison, so −10 ≤ −3 and 9 ≤ 10 both hold. Sorting as text would instead place −10 before −3 by accident and 10 before 9 by the same accident, because it compares character by character from the left rather than by value
- −10, −3, 0, 4, 7, 12.5
- The sorted output, and a permutation of the input — six values in, six values out, the same six. This is the invariant to check if you ever doubt the result: the count must match, and every value you put in must appear exactly as many times as you put it in. Nothing on this page adds, removes or combines numbers
- minimum = −10
- The first element of the sorted list, taken from it rather than found by a separate scan. On a number line it is the leftmost point. It is not the same as the smallest-looking entry in the input: −10 looks shorter than −3, and it is the smaller number
- maximum = 12.5
- The last element of the sorted list, again read off rather than searched for. The gap between this and the minimum is the range, which is the one statistic that needs nothing but these two outputs — and range-calculator computes exactly that from the same pair
- 3, 5, 5
- What duplicates do. The input 5, 5, 3 sorts to 3, 5, 5 — the repeat survives. Dropping it would be tidier to look at and would break the invariant above, and it would also silently change the answer to any question about how many values there are, including the median
Reading a median is the most common reason to sort: the median is the middle value of the sorted list, or the average of the middle two when the count is even, and neither can be read off an unsorted list at all. The same is true of quartiles and percentiles, which are defined by position in the sorted order. A second use is the range, which is just the largest value minus the smallest, and this page prints both of those numbers directly — range-calculator does the subtraction if that is all you want. A third is the ordinary human one: a column of measurements, prices, ages or scores pasted in from a spreadsheet is much easier to read once it is in order, because the extremes jump out and clusters become visible. That is the same reason a sorted list is the first thing you plot, since a frequency count or a histogram both start from it. A fourth use is checking a spreadsheet's own sort. Sorting as text rather than as numbers is a common mistake in spreadsheet software when a column has been formatted oddly, and the symptom is exactly the error described above — 10 before 9, or 12.5 before 4. If a sorted column looks wrong to you, running the same values through this page tells you which of the two is misreading the input. Once the list is in order, the descriptive neighbours take over: median-calculator reads the middle, range-calculator the two ends, quartile-calculator the quarter positions, and average-calculator the mean, which is the one of these that does not care about order.
Worked examples
Mixed signs and a decimal: 7; −3; 12.5; 0; −10; 4
- Find the smallest value first: −10 is further left than anything else in the list
- Then the next smallest, −3, then 0, then 4, then 7
- 12.5 is the largest, so it goes last
- The sorted list is −10, −3, 0, 4, 7, 12.5, and its two ends give the minimum and the maximum
The default input, and deliberately an awkward one: it has two negatives, a positive decimal and a zero, so it exercises both of the traps at once. Note that −10 sorts first even though −3 is the longer-looking number of the two, and that 12.5 sorts after 7 even though 12.5 starts with the same digit as 1. Sorting these as text would give −10, −3, 0, 12.5, 4, 7 — the negative end would look right by accident and the decimal would land in the wrong place.
The trap that single digits hide: 9; 10; 100; 2
- Compare by value, not by first digit: 2 is smaller than 9
- 10 is larger than 9 but smaller than 100
- The order is 2, 9, 10, 100
- The smallest is 2 and the largest is 100
Four short numbers, all positive, and the list that catches text sorting. Comparing as strings puts 10 first and 2 last, because the comparison stops at the first character: 1 comes before 2 comes before 9. The correct order comes from comparing values, and the sign that something has gone wrong is that the result does not look like a number line — there is no arrangement of the digits in which 10 sits before 2. This is the case worth testing any sorting code against, because a list of single digits sorts correctly either way.
Negatives in the other order: −5; −20; −3
- On a number line, −20 is the furthest left of the three
- −5 is to its right, and −3 is the rightmost of the three
- So the ascending order is −20, −5, −3
- The minimum is −20 — the largest-looking number in the list
The mirror of the previous example, and the one that catches readers rather than code. −20 is the smallest of the three even though its digits are the largest, because further left on the line means smaller. Text sorting happens to get this right — the string −20 does come before −5 — so the negative case is where a text sort looks correct while a positive multi-digit list is where it fails. Between them, the two examples cover both directions, which is why they are both here.
Limitations
The list takes between 1 and 200 numbers, separated by commas, semicolons or spaces, and all three may be mixed in one list. Two hundred is a limit on how long a list the page will accept, not a performance guard — larger lists are not slow, they are refused, because a field this long stops being editable and the answer stops being readable. Numbers may be negative, may have decimals and may be zero, and duplicates are kept rather than removed. Thousands separators are not understood: a comma followed by a space separates entries, while a comma sitting between two digits with no space after it is read as a decimal point (1,5 is one and a half). The thousands shape 1,500 is neither, so 1500 and 1.5 cannot be told apart and it is refused outright rather than guessed at — a column pasted from a spreadsheet that groups large numbers is rejected, not quietly misread. Strip the separators before pasting. Exponent notation is not understood either, so 1e5 is refused rather than read as 100000. The output is a canonical spelling of each value rather than a copy of what you typed: 12.50 prints as 12.5, +7 prints as 7, and −0 prints as 0. Very large values switch to exponent notation in the output, at 10²¹ and above, which is the point where the number-to-text conversion changes notation on its own; flattening that would mean writing a second number formatter, and the page does not have one. There is no reference table on this page: a table is for showing which band a result falls into, and sorting has no bands. Ascending order is the only direction offered — for descending order, read the output right to left.
Frequently asked questions
- How do I sort a list that has both negatives and decimals?
- Paste it in and let the page do it — the separator can be a comma, a semicolon or a space, and all three can be mixed. Negatives and decimals make no difference to the rule, which is simply that a smaller number goes further left. The one thing to watch for is that −20 is smaller than −3 despite having more digits, and that 12.5 is larger than 4 despite starting with a 1. Comparing values rather than the text of the numbers is the whole of the correctness here.
- Does the order I type the numbers in matter?
- Not at all — the page sorts whatever it is given, and the same set of values always produces the same output regardless of the order they arrived in. That is what makes the result checkable: sort a list, then sort it again and the output is identical, because there is only one ascending order for a given set of values. Duplicates are the only place the input's shape survives, since 5, 5, 3 and 3, 5, 5 both sort to 3, 5, 5.
- Are duplicate values removed?
- No, and that is deliberate. The output is the input rearranged, so it has to contain exactly the numbers you gave, each as many times as you gave it. Removing repeats would be a different operation — it is called deduplication, and it changes the answer to every question about the list, including how many values there are and what the median is. If you want a list of distinct values, that is a separate step, and it should be a visible one.
- Why did 12.50 come back as 12.5?
- Because trailing zeros are not part of a value, and the page prints the canonical spelling of each number rather than copying what you typed. The same normalisation turns +7 into 7 and −0 into 0. It is the one place where the output is not quite a copy of the input, and it is worth knowing about if the formatting of your numbers carries meaning to you — for currency, say, where 12.50 and 12.5 read differently to a person even though they are the same number.
- Can I sort from greatest to least instead?
- The page gives ascending order, and descending order is that same output read right to left — there is nothing extra to compute, since reversing a sorted list gives the reverse order immediately. The page offers only the one direction because it is the one every downstream statistic wants: the median, the quartiles and the range are all defined from the ascending list, and a descending one would have to be reversed before any of them could be read.
- Why was my pasted spreadsheet column rejected?
- Almost certainly thousands separators. On this page a comma followed by a space separates entries, and a comma between two digits with no space after it is read as a decimal point; the shape 1,500 is neither, so 1500 and 1.5 cannot be told apart and the whole list is refused rather than guessed at. Exponent notation is refused in the same way: 1e5, not 100000. Strip the separators before pasting.
References
- Sorting — the general problem of putting a collection in order, and why comparison-based sorting is its own field of study — Wolfram MathWorld (United States)
- Ordering — what a total order is, and the properties a comparison has to have before a list can be sorted by it at all — Wolfram MathWorld (United States)
- Real Line — the picture that makes 'least to greatest' mean left to right, including for negative numbers — Wolfram MathWorld (United States)
- 教育部关于印发义务教育课程方案和课程标准(2022 年版)的通知——The fifth item in the annex list of this notice is the Mathematics Curriculum Standards for Compulsory Education (2022 edition); comparing the size of numbers and the number line are part of the Number and Algebra strand at the primary school level, and the wording of the standards and the grade-band breakdown are governed by that annex — 中华人民共和国教育部