A solution to this problem is quite straightforward: You keep “flipping” the largest unsorted pancake until all pancakes are sorted.