def pancake_sort(arr):
len_arr = len(arr)<EOL>if len_arr <= <NUM_LIT:1>:<EOL><INDENT>return arr<EOL><DEDENT>for cur in range(len(arr), <NUM_LIT:1>, -<NUM_LIT:1>):<EOL><INDENT>index_max = arr.index(max(arr[<NUM_LIT:0>:cur]))<EOL>if index_max+<NUM_LIT:1> != cur:<EOL><INDENT>if index_max != <NUM_LIT:0>:<EOL><INDENT>arr[:index_max+<NUM_LIT:1>] = reversed(arr[:index_max+<NUM_LIT:1>])<EOL><DEDENT>arr[:cur] = reversed(arr[:cur])<EOL><DEDENT><DEDENT>return arr<EOL>
Pancake_sort
Sorting a given array
mutation of selection sort

reference: https://www.geeksforgeeks.org/pancake-sorting/

Overall time complexity : O(N^2)