Simple Card Sort

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 below:

Simple Card Sort Algorithm

  1. 1. Get a hand of unsorted cards
  2. 2. Repeat steps 3 through 5 until the unsorted hand is empty
  3. 3.    Compare unsorted cards
  4. 4.    Select the smallest unsorted card
  5. 5.    Move this card to the sorted hand
  6. 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.