This is an easy-to-understand algorithm for sorting. Computer scientists called it "Bubble sort", because smaller elements will rise to the top, changing their position in each run. Unfortunately, the algorithm is not very good, because it needs a long time (many passes through the stack of cards) to sort it.