To order a list of whole numbers is to arrange it from the least to the greatest or from the greatest to the least. This lesson defines both orders, proves that a list of different numbers has exactly one such arrangement, gives a place-value method for ordering many large numbers, and shows why numerals must not be sorted like words in a dictionary.
Increasing and decreasing order
This lesson uses the number line of lesson 1.1, the comparison of whole numbers by place value proved in lesson 1.2, and two facts proved in Counting, lesson 1.4: the order is transitive (if a < b and b < c, then a < c), and every collection of whole numbers that is not empty has a smallest member.
A list of whole numbers is:
- in increasing order, also called ascending order, if each number in it is less than the number after it: the smallest comes first;
- in decreasing order, also called descending order, if each number in it is greater than the number after it: the largest comes first.[1]
To order a list, or to sort it, is to rearrange its numbers into one of these orders.[2]
An increasing list is written as a chain of inequalities, such as 2 < 5 < 9 < 11. The chain is shorthand for “2 < 5 and 5 < 9 and 9 < 11”; in the same way, a < x < b says that x lies between a and b.[3] A decreasing list is written with >: 11 > 9 > 5 > 2.
In a list in increasing order, every number is less than every number that comes after it, not only the next one. In a list in decreasing order, every number is greater than every number after it.
Take two places in an increasing list, with the number a first and the number c later. Between them the list steps from each number to the next, and each step goes to a greater number. By transitivity, a is less than the second number after it, then less than the third, and so on, until c: a < c. For a decreasing list the same argument works with >.
A list of different whole numbers can be arranged in increasing order in exactly one way. Read backward, that arrangement is the only arrangement in decreasing order.
There is an arrangement. The list is not empty, so it has a smallest number (Counting, lesson 1.4); put it first. The numbers left over, if any, again have a smallest; put it second. Continue until no number is left; the list is finite, so this ends. Each number placed is the smallest of those still left, and the numbers of the list are different, so it is less than every number placed after it.
There is only one. In any increasing arrangement, the first number is less than all the others, by the Proposition, so it is the smallest number of the list. The list has only one smallest number: if m and m′ were both smallest, then m ≤ m′ and m′ ≤ m, so m = m′ by trichotomy. So every increasing arrangement starts with the same number. Remove it: what remains of each arrangement is an increasing arrangement of the same remaining numbers, so the second numbers agree too, and so on to the end.
Decreasing order. a < b says the same as b > a, so reading an increasing list backward gives a decreasing one, and reading a decreasing list backward gives an increasing one. Since there is exactly one increasing arrangement, there is exactly one decreasing arrangement.
On the number line the increasing order is simply the order of the points from left to right, because a smaller number lies to the left (lesson 1.1). Textbooks use the number line in this way to compare and order numbers: going from left to right, numbers increase in value.[4] Sorting is a standard task in mathematics and computing: sorting the list 7, 2, 1, 4, 5, 9, for example, gives 1, 2, 4, 5, 7, 9.[2]
Put 9, 2, 11, 5 in increasing order, then in decreasing order.
- The smallest is 2: it is less than 9, 11 and 5. Put it first.
- Of 9, 11, 5 the smallest is 5. Then, of 9 and 11, the smaller is 9. Last comes 11.
- Check each neighbor: 2 < 5, 5 < 9, 9 < 11. The figure above shows the same order from left to right.
- Reading backward gives the decreasing order.
Answer: 2 < 5 < 9 < 11, and 11 > 9 > 5 > 2.
Order the list 4, 0, 7, 4, 1 from the least to the greatest.
- 0 is the smallest whole number, so it comes first. Then 1.
- The number 4 appears twice. The two copies are equal, so neither is less than the other: they stand next to each other, in either order.
- Last comes 7.
Answer: 0, 1, 4, 4, 7, written 0 < 1 < 4 ≤ 4 < 7 or simply 0 ≤ 1 ≤ 4 ≤ 4 ≤ 7. With repeated numbers no list can be in strictly increasing order; the list is then called nondecreasing: each number is at least as large as the one before it.[5]
The smallest and the largest
The first number of the increasing order is the smallest of the list, and the last is the largest. To find the largest without ordering the whole list, go through the list once, keeping a “largest so far”: start with the first number, compare it with each next number, and replace it whenever the next number is greater.[6]
When the list has been gone through, the number kept is the largest number of the list.
After the first number has been looked at, the number kept is the largest of the numbers looked at so far, because it is the only one. Suppose this holds after some number of steps, and look at the next number. If it is greater than the number kept, it is greater than all the numbers looked at before (transitivity), and it is kept: it is the largest so far. If it is not greater, the number kept is at least as large as it, and stays the largest so far. So the statement holds after every step, and in particular at the end, when every number has been looked at.
Find the largest of 3,409; 3,940; 3,094; 3,490.
- Keep 3,409.
- Compare with 3,940: same number of digits, thousands agree, hundreds 4 < 9. 3,940 is greater: keep 3,940.
- Compare with 3,094: hundreds 9 > 0, so 3,940 stays.
- Compare with 3,490: hundreds 9 > 4, so 3,940 stays.
Answer: 3,940 is the largest. It took three comparisons, one fewer than the number of numbers.
Ordering many large numbers
The two theorems of lesson 1.2 give a method that orders a whole list at once, without comparing every pair.
- Group by the number of digits. Every number in a group with fewer digits is less than every number in a group with more digits (Theorem 1), so in increasing order the groups come with the fewest digits first.
- Within a group, order by the first digit. Numbers with the same number of digits and different first digits are ordered by those digits (Theorem 2).
- Break ties with the next digit. Numbers that share their first digit are ordered by their second digit; those that share the first two, by the third; and so on (Theorem 2).
Put in increasing order: 4,503; 987; 4,530; 12,001; 4,035; 990.
- Group by digits. Three digits: 987, 990. Four digits: 4,503; 4,530; 4,035. Five digits: 12,001.
- Three digits: hundreds agree (9 and 9); tens 8 < 9, so 987 < 990.
- Four digits: all have thousands digit 4. Hundreds: 4,035 has 0, the others have 5, so 4,035 comes first. 4,503 and 4,530 agree in the hundreds too; tens 0 < 3, so 4,503 < 4,530.
- Five digits: only 12,001, which comes last.
Answer: 987 < 990 < 4,035 < 4,503 < 4,530 < 12,001. Check: each neighbor pair was compared by Theorem 1 or 2.
Put them in order
- Round
- 1
- Score
- 0
- Streak
- 0
Tap the numbers in increasing order, from the least to the greatest.
Numerals are not words
Words in a dictionary are ordered letter by letter: two words are compared at the first letter where they differ, and when one word is the beginning of a longer word, the shorter one comes first.[7] Numerals sorted the same way, digit by digit as strings of characters, come out in the wrong order whenever their lengths differ: “10” comes before “9”, because its first character, 1, comes before 9.
Like words
- 1
- 10
- 100
- 11
- 2
- 20
- 3
- 9
As numbers
- 1
- 2
- 3
- 9
- 10
- 11
- 20
- 100
A list of page numbers 1, 2, 3, 9, 10, 11, 20, 100 is sorted letter by letter, like words. What order results, and how can it be repaired?
- All numerals beginning with the character 1 come first: “1”, then “10” (it begins with “1”), then “100” (it begins with “10”), then “11”.
- Then those beginning with 2: “2”, “20”. Then “3”, and last “9”.
- The result 1, 10, 100, 11, 2, 20, 3, 9 is not increasing: 100 comes before 11, and 9 comes last.
- Repair: write every numeral with the same number of digits by adding zeros in front: 001, 002, 003, 009, 010, 011, 020, 100. Zeros in front do not change a number (lesson 1.2). Now all the numerals have three digits, and for numerals of the same length comparing digit by digit from the left is exactly Theorem 2. (Its proof never uses that the first digit is not 0: a 0 in front only records that there are no groups of that place.) So the letter-by-letter order is the increasing order.
Answer: letter by letter gives 1, 10, 100, 11, 2, 20, 3, 9; with zeros in front it gives the right order 1, 2, 3, 9, 10, 11, 20, 100.
Step 1 of the method, grouping by the number of digits, is what separates ordering numbers from ordering words. Skipping it is the mistake in the example above.
Numbers between two numbers
The whole numbers x with a < x < b are those that come after a and before b in the counting list. On the number line their points lie strictly between the points of a and b.[3] With ≤ in place of <, the ends a and b are included.
Which whole numbers x satisfy 38 < x < 45? How many are there? And 38 ≤ x ≤ 45?
- After 38 in the counting list come 39, 40, 41, 42, 43, 44, and then 45, which is not less than 45.
- Count them: “one, two, three, four, five, six”. There are 6.
- With ≤, the numbers 38 and 45 also qualify: 38, 39, …, 45, which is 8 numbers.
Answer: 39, 40, 41, 42, 43, 44, six numbers; with ≤ at both ends, eight numbers.
Is there a whole number x with 44 < x < 45?
- 45 is the successor of 44.
- No whole number lies between a number and its successor (Counting, lesson 1.4).
Answer: no. On the number line, the marks of 44 and 45 are neighbors.
Using each of the digits 3, 0, 7, 5 exactly once, write the largest and the smallest four-digit whole numbers.
- All the numbers have four digits, so Theorem 2 of lesson 1.2 compares them from the left: the first digit matters most, then the second, and so on.
- Largest: put the greatest digit first, then the greatest of the rest, and so on: 7, 5, 3, 0, giving 7,530.
- Smallest: the first digit should be the least, but a four-digit numeral cannot begin with 0, so the first digit is 3. Then the rest in increasing order: 0, 5, 7, giving 3,057.
- Check: 0357, with the 0 in front, is the numeral 357, which has only three digits.
Answer: 7,530 and 3,057.
Exercises
Put in increasing order: 506; 56; 5,006; 560; 65.
▸ Show solution
Two digits: 56, 65, with 56 < 65 (tens 5 < 6). Three digits: 506, 560, with 506 < 560 (hundreds agree, tens 0 < 6). Four digits: 5,006. Answer: 56 < 65 < 506 < 560 < 5,006.
Put in decreasing order: 23,910; 23,190; 29,310; 3,999.
▸ Show solution
Four digits: 3,999, which comes last in decreasing order. Five digits: 23,910; 23,190; 29,310. All start with 2; second digits 3, 3, 9, so 29,310 is the greatest. 23,910 and 23,190 agree in their first two digits; third digits 9 > 1. Answer: 29,310 > 23,910 > 23,190 > 3,999.
How many whole numbers x satisfy 96 < x < 103? List them.
▸ Show solution
The whole numbers after 96 and before 103 are 97, 98, 99, 100, 101, 102. Counting them gives 6. (99 and 100 are neighbors on the number line: 100 is the successor of 99.)
Using all five digits 4, 0, 9, 1, 1 (so the digit 1 is used twice), write the largest and the smallest five-digit whole numbers.
▸ Show solution
Largest: the digits from greatest to least, 9, 4, 1, 1, 0, give 94,110. By Theorem 2, any other arrangement has, at the first place where it differs from 94,110, a smaller digit.
Smallest: the first digit cannot be 0, so it is the least other digit, 1. The remaining digits 0, 1, 4, 9 follow in increasing order: 10,149.
Twelve files are named page1, page2, …, page12. In what order do they appear when the names are sorted letter by letter, like words? How can the names be changed so that this order is the increasing order of the numbers?
▸ Show solution
Letter by letter, the names agree up to “page”; then the numerals decide character by character: page1, page10, page11, page12, page2, page3, …, page9. So page10 to page12 come between page1 and page2.
Repair: write the numbers with two digits, page01, page02, …, page09, page10, page11, page12. All numerals now have the same length, so the letter-by-letter order is the increasing order (Theorem 2 of lesson 1.2).
Prove that the first number of a list in increasing order is its smallest number, and that the same list read backward is in decreasing order.
▸ Show solution
Let the list be in increasing order, and let s be its first number. By the Proposition of the first section, s is less than every later number, so s is the smallest; this is the first claim.
Read the list backward. Each pair of neighbors a, b with a < b becomes b, a with b > a. So in the backward list each number is greater than the next: it is in decreasing order.
Summary
- A list is in increasing (ascending) order if each number is less than the next, and in decreasing (descending) order if each is greater than the next.
- In an increasing list each number is less than every later number; a list of different numbers has exactly one increasing arrangement, and reading it backward gives the only decreasing one.
- The largest of a list is found in one pass by keeping the largest so far.
- To order many numbers: group by the number of digits, then order each group digit by digit from the left.
- Numerals must not be sorted like words: “10” would come before “9”. Writing them all with the same number of digits repairs this.
- The whole numbers with a < x < b are those after a and before b in the counting list; there are none between a number and its successor.
Sources
- 1.“in ascending/descending order”, Cambridge Dictionary, Cambridge University Press.Section “Meaning of in ascending/descending order in English”. dictionary.cambridge.org/dictionary/english/in-ascending-descending-order · open at the quoted passage.
“data or information that is arranged in ascending order is arranged so that the smallest or least important numbers, facts, etc. are shown first; data or information that is arranged in descending order is arranged so that the largest or most important numbers, facts, etc. are shown first”
Used for: ascending order puts the smallest number first and descending order the largest number first. - 2.Kenneth H. Rosen, Discrete Mathematics and Its Applications (8th ed., McGraw-Hill, 2019).Chapter 3, “Algorithms”, section 3.1, “Algorithms” (3.1.3, “Sorting”), p. 206 (the whole topic: pp. 206–208).
“Sorting is putting these elements into a list in which the elements are in increasing order. For instance, sorting the list 7, 2, 1, 4, 5, 9 produces the list 1, 2, 4, 5, 7, 9.”
Used for: to sort a list is to put its numbers in increasing order; sorting 7, 2, 1, 4, 5, 9 gives 1, 2, 4, 5, 7, 9. - 3.Kenneth H. Rosen, Discrete Mathematics and Its Applications (8th ed., McGraw-Hill, 2019).Chapter 2, “Basic Structures: Sets, Functions, Sequences, Sums, and Matrices”, section 2.1, “Sets” (2.1.1, “Introduction”), p. 123 (the whole topic: pp. 122–123).
“Among the sets studied in calculus and other subjects are intervals, sets of all the real numbers between two numbers a and b, with or without a and b.”
Used for: a < x < b says that x lies between a and b, with ≤ including the ends (the same page writes these sets as {x | a < x < b}, {x | a ≤ x ≤ b} and so on). - 4.Lynn Marecek, MaryAnne Anthony-Smith and Andrea Honeycutt Mathis, Prealgebra (2nd ed., OpenStax, Rice University, 2020).Chapter 3, “Integers”, section 3.1, “Introduction to Integers” (“Order Positive and Negative Numbers”), p. 173 (the whole topic: pp. 173–175).
“We can use the number line to compare and order positive and negative numbers. Going from left to right, numbers increase in value.”
Used for: the number line is used to compare and order numbers: going from left to right, numbers increase in value. - 5.Kenneth H. Rosen, Discrete Mathematics and Its Applications (8th ed., McGraw-Hill, 2019).Chapter 3, “Algorithms”, section 3.1, “Algorithms”, Exercises (exercise 5), p. 214 (the whole topic: pp. 214).
“Recall that a list of integers is nondecreasing if each integer in the list is at least as large as the previous integer in the list.”
Used for: a list in which each number is at least as large as the one before is called nondecreasing. - 6.Kenneth H. Rosen, Discrete Mathematics and Its Applications (8th ed., McGraw-Hill, 2019).Chapter 3, “Algorithms”, section 3.1, “Algorithms” (3.1.1, “Introduction”), Example 1, p. 202 (the whole topic: pp. 201–203).
“Set the temporary maximum equal to the first integer in the sequence. (The temporary maximum will be the largest integer examined at any stage of the procedure.)”
Used for: the largest number of a list is found by keeping a largest so far, starting with the first number and replacing it whenever a greater number is met (the next steps of the same solution). - 7.Kenneth H. Rosen, Discrete Mathematics and Its Applications (8th ed., McGraw-Hill, 2019).Chapter 9, “Relations”, section 9.6, “Partial Orderings” (9.6.2, “Lexicographic Order”), p. 654 (the whole topic: pp. 652–654).
“One string is less than another string if the t-tuple corresponding to the first string is less than the t-tuple of the second string, or if these two t-tuples are the same, but the second string is longer.”
Used for: in dictionary (lexicographic) order, strings are compared at the first place where they differ, and a string that is the beginning of a longer one comes first (t is the length of the shorter string).