nodes: 0, module; 1, function_definition; 2, function_name:pancake_sort; 3, parameters; 4, block; 5, identifier:arr; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, for_statement; 10, return_statement; 11, comment:"""
      Pancake_sort
      Sorting a given array
      mutation of selection sort
  
      reference: https://www.geeksforgeeks.org/pancake-sorting/
      
      Overall time complexity : O(N^2)
      """; 12, assignment; 13, comparison_operator:len_arr <= 1; 14, block; 15, identifier:cur; 16, call; 17, comment:#Finding index of maximum number in arr; 18, block; 19, identifier:arr; 20, identifier:len_arr; 21, call; 22, identifier:len_arr; 23, integer:1; 24, return_statement; 25, identifier:range; 26, argument_list; 27, expression_statement; 28, if_statement; 29, identifier:len; 30, argument_list; 31, identifier:arr; 32, call; 33, integer:1; 34, unary_operator; 35, assignment; 36, comparison_operator:index_max+1 != cur; 37, comment:#Needs moving; 38, block; 39, identifier:arr; 40, identifier:len; 41, argument_list; 42, integer:1; 43, identifier:index_max; 44, call; 45, binary_operator:index_max+1; 46, identifier:cur; 47, if_statement; 48, comment:# Reverse list; 49, expression_statement; 50, identifier:arr; 51, attribute; 52, argument_list; 53, identifier:index_max; 54, integer:1; 55, comparison_operator:index_max != 0; 56, comment:#reverse from 0 to index_max; 57, block; 58, assignment; 59, identifier:arr; 60, identifier:index; 61, call; 62, identifier:index_max; 63, integer:0; 64, expression_statement; 65, subscript; 66, call; 67, identifier:max; 68, argument_list; 69, assignment; 70, identifier:arr; 71, slice; 72, identifier:reversed; 73, argument_list; 74, subscript; 75, subscript; 76, call; 77, identifier:cur; 78, subscript; 79, identifier:arr; 80, slice; 81, identifier:arr; 82, slice; 83, identifier:reversed; 84, argument_list; 85, identifier:arr; 86, slice; 87, integer:0; 88, identifier:cur; 89, binary_operator:index_max+1; 90, subscript; 91, identifier:cur; 92, identifier:index_max; 93, integer:1; 94, identifier:arr; 95, slice; 96, binary_operator:index_max+1; 97, identifier:index_max; 98, integer:1
code: def pancake_sort(arr):
      """
      Pancake_sort
      Sorting a given array
      mutation of selection sort
  
      reference: https://www.geeksforgeeks.org/pancake-sorting/
      
      Overall time complexity : O(N^2)
      """
  
      len_arr = len(arr)
      if len_arr <= 1:
          return arr
      for cur in range(len(arr), 1, -1):
          #Finding index of maximum number in arr
          index_max = arr.index(max(arr[0:cur]))
          if index_max+1 != cur:
              #Needs moving
              if index_max != 0:
                  #reverse from 0 to index_max
                  arr[:index_max+1] = reversed(arr[:index_max+1])
              # Reverse list
              arr[:cur] = reversed(arr[:cur])
      return arr