Algorithm
This algorithm goes through the stack of cards, one card at a time. This card is compared to the next card in the stack. Please note that this position only changes in step 6.  This algorithm is called bubble sort. It is slow.