nodes: 0, module; 1, function_definition; 2, function_name:sort_list_of_dicts; 3, parameters; 4, block; 5, identifier:lst_of_dct; 6, identifier:keys; 7, default_parameter; 8, dictionary_splat_pattern; 9, expression_statement; 10, if_statement; 11, comment:# dcmdir = lst_of_dct[:]; 12, comment:# lst_of_dct.sort(key=lambda x: [x[key] for key in keys], reverse=reverse, **sort_args); 13, expression_statement; 14, return_statement; 15, identifier:reverse; 16, False; 17, identifier:sort_args; 18, comment:"""
      Sort list of dicts by one or multiple keys.
  
      If the key is not available, sort these to the end.
  
      :param lst_of_dct: input structure. List of dicts.
      :param keys: one or more keys in list
      :param reverse:
      :param sort_args:
      :return:
      """; 19, comparison_operator:type(keys) != list; 20, block; 21, call; 22, identifier:lst_of_dct; 23, call; 24, identifier:list; 25, expression_statement; 26, attribute; 27, argument_list; 28, identifier:type; 29, argument_list; 30, assignment; 31, identifier:lst_of_dct; 32, identifier:sort; 33, keyword_argument; 34, keyword_argument; 35, dictionary_splat; 36, identifier:keys; 37, identifier:keys; 38, list; 39, identifier:key; 40, lambda; 41, identifier:reverse; 42, identifier:reverse; 43, identifier:sort_args; 44, identifier:keys; 45, lambda_parameters; 46, list_comprehension; 47, identifier:x; 48, parenthesized_expression; 49, for_in_clause; 50, conditional_expression:(False, x[key]) if key in x else (True, 0); 51, identifier:key; 52, identifier:keys; 53, tuple; 54, comparison_operator:key in x; 55, tuple; 56, False; 57, subscript; 58, identifier:key; 59, identifier:x; 60, True; 61, integer:0; 62, identifier:x; 63, identifier:key
code: def sort_list_of_dicts(lst_of_dct, keys, reverse=False, **sort_args):
      """
      Sort list of dicts by one or multiple keys.
  
      If the key is not available, sort these to the end.
  
      :param lst_of_dct: input structure. List of dicts.
      :param keys: one or more keys in list
      :param reverse:
      :param sort_args:
      :return:
      """
  
      if type(keys) != list:
          keys = [keys]
      # dcmdir = lst_of_dct[:]
      # lst_of_dct.sort(key=lambda x: [x[key] for key in keys], reverse=reverse, **sort_args)
      lst_of_dct.sort(key=lambda x: [((False, x[key]) if key in x else (True, 0)) for key in keys], reverse=reverse, **sort_args)
      return lst_of_dct