A list of marks, a list of prices, the children of a class by height: a great many problems start with "put these in order", and a great many others become easy the moment the data is in order. This lesson is about sorting — first doing it by hand once, to see what it costs, and then letting C++ do it.
What "sorted" means
A vector is sorted in increasing order when every element is at least as
large as the one before it: a[i - 1] <= a[i] for every i. Equal values are
allowed next to each other, so 1 3 3 7 is sorted. Sorting rearranges the
values and nothing else: the same numbers, the same number of copies of each,
in a new order.
Read n marks. Print them from the lowest to the highest, and then the top three.
Sorting by hand: selection sort
Here is how a person would do it with a row of cards. Find the smallest card and swap it to the front. Then find the smallest of the rest and swap it into second place. Keep going; each turn fixes one more position for good. This is selection sort, because every turn selects the smallest of what is left: