code: def eval_field(field, asc):
      if isinstance(field, dict):
          if asc:
              return field
          else:
              field = copy.deepcopy(field)
              key = list(field.keys())[0]
              field[key]['order'] = reverse_order(field[key]['order'])
              return field
      elif callable(field):
          return field(asc)
      else:
          key, key_asc = parse_sort_field(field)
          if not asc:
              key_asc = not key_asc
          return {key: {'order': 'asc' if key_asc else 'desc'}}