Sorting an Array of Items

One of the most frequent tasks the computer must perform is sorting. In order to sort items efficiently they must be stored in an array. There are several way in which the computer can sort a list numerically or alphabetically. We will study two methods; one referred to as bubble sort and the other the selection sort. There are other methods. These two are the easiest to understand and code but not necessarily the most efficient.

General Rule: the quicker the sort, the more difficult it is to program!

Bubble Sort BiDirectional Bubble Sort Quick Sort

Click on a Java applet and watch the sort work. Notice the different way in which each sorts the same stack of pencils. Also notice the difference in sorting speed. Which do you think is the easiest to program? Which is the most difficult?

Some governments and companies have large amounts of data that must be sorted. Studying a program's efficiency is one important aspect of Computer Science