Sorting, that is ordering a collection of objects in ascending or descending order, is something that often needs to be done when writing large programs. In this lesson, you will teach Reeborg some sorting skills.
As a warming up exercise, write a program so that Reeborg will arrange, or sort, two vertical piles of beepers. Here are two typical situations:
How difficult would it be to change your program so that the piles are sorted in descending order?
The following exercise is quite a bit more challenging. You have to write a program so that Reeborg will sort an unknown number of vertical piles of beepers into ascending order. The first empty pile marks the end of the piles that need to be sorted. Here's a typical example.
How difficult would it be to change your program to sort the piles into descending order?