Sorting the Pancakes in Python