CPS 49S: Sorting
Meredith Maltese and Jason Fink
- Compare first 2 rectangles and decide which is taller.
- Move the rectangles so that the smaller one is on the left.
- Compare the third rectangle with the second one so that the
smaller one is on the left. If you switch them, proceed to compare
the new second rectangle to the first, so that the smallest one is on
the left.
- Compare the fourth rectangle with the rectangle in the third
spot. Place the smallest one on the left. If you move the rectangle
to the third spot, then compare it to the rectangle in the second
spot, and move it so that the smallest rectangle is on the left. If
you move the rectangle into the second spot, compare it to the first
rectangle, and move it so that the smallest rectangle is on the left.
- Continue this process with all the rectangles in the group, so
that at the end, you're comparing rectangle ten with all the others.