One basic algorithm for sorting is the Simple Sort. We can illustrate this algorithm using a group of unsorted playing cards. The Simple Sort sort works by selecting the smallest card in the unsorted hand and moving this card to a second hand. Once all the cards have been removed from the unsorted hand, the second hand contains the cards in sorted order. The algorithm for the Simple Sort is given in the box below.


Simple Card Sort Algorithm

  1. Get a hand of unsorted cards
  2. Repeat steps 3 through 5 until the unsorted hand is empty
  3.    Compare unsorted cards
  4.    Select the smallest unsorted card
  5.    Move this card to the sorted hand
  6. Stop

Most of the steps in this algorithm are simple, but the third step needs a little more explanation. In order to be certain that we are selecting the smallest card, we need to compare all the cards in our hand. We can do this by comparing the first two cards and keeping the smaller of the two. Then we can compare this card to the remaining cards until we find a smaller one or check all the cards.

To see how the Simple Card Sort Algorithm works, click on the animation below. As the sort progresses, the appropriate step of the algorithm will be highlighted in the bottom left panel of the animation. Also, we will keep track of the current cards we are comparing by pointing to them with a pair of human hands. The left hand will point to the smallest card so far, and the right hand will point to the current card for comparison.

[View in New Window]


Text-only version