def _handle_sort_key(model_name, sort_key=None):
 sort_keys_extra = {'meter': ['user_id', 'project_id'], 'resource': ['user_id', 'project_id', 'timestamp']}
 sort_keys = sort_keys_extra[model_name]
 if (not sort_key):
  return sort_keys
 try:
  sort_keys.remove(sort_key)
 except ValueError:
  pass
 finally:
  sort_keys.insert(0, sort_key)
 return sort_keys

def _handle_sort_key ( model_name , sort_key = None ) : sort_keys_extra = { 'meter' : [ 'user_id' , 'project_id' ] , 'resource' : [ 'user_id' , 'project_id' , 'timestamp' ] } sort_keys = sort_keys_extra [ model_name ] if ( not sort_key ) : return sort_keys try : sort_keys . remove ( sort_key ) except ValueError : pass finally : sort_keys . insert ( 0 , sort_key ) return sort_keys
generate sort keys according to the passed in sort key from user .