nodes: 0, module; 1, function_definition; 2, function_name:sort_potentials; 3, parameters; 4, block; 5, identifier:potentials; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, comment:# Sort by increasing AM, then move the last element to the front; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:use_copy; 14, True; 15, comment:"""
      Sort a list of ECP potentials into a standard order
  
      The order within a potential is not modified.
  
      The order of the shell list is in increasing angular momentum, with the largest
      angular momentum being moved to the front.
  
      If use_copy is True, the input potentials are not modified.
      """; 16, identifier:use_copy; 17, block; 18, assignment; 19, call; 20, identifier:potentials; 21, expression_statement; 22, identifier:potentials; 23, call; 24, attribute; 25, argument_list; 26, assignment; 27, identifier:list; 28, argument_list; 29, identifier:potentials; 30, identifier:insert; 31, integer:0; 32, call; 33, identifier:potentials; 34, call; 35, call; 36, attribute; 37, argument_list; 38, attribute; 39, argument_list; 40, identifier:sorted; 41, argument_list; 42, identifier:potentials; 43, identifier:pop; 44, identifier:copy; 45, identifier:deepcopy; 46, identifier:potentials; 47, identifier:potentials; 48, keyword_argument; 49, identifier:key; 50, lambda; 51, lambda_parameters; 52, subscript; 53, identifier:x; 54, identifier:x; 55, string; 56, string_content:angular_momentum
code: def sort_potentials(potentials, use_copy=True):
      """
      Sort a list of ECP potentials into a standard order
  
      The order within a potential is not modified.
  
      The order of the shell list is in increasing angular momentum, with the largest
      angular momentum being moved to the front.
  
      If use_copy is True, the input potentials are not modified.
      """
  
      if use_copy:
          potentials = copy.deepcopy(potentials)
  
      # Sort by increasing AM, then move the last element to the front
      potentials = list(sorted(potentials, key=lambda x: x['angular_momentum']))
      potentials.insert(0, potentials.pop())
      return potentials