Pancake sorting algorithm