code: def eval_field(field, asc):
      
      if isinstance(field, dict):
          if asc:
              return field
          else:
              # Field should only have one key and must have an order subkey.
              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'}}
docs: Evaluate a field for sorting purpose.
  
      :param field: Field definition (string, dict or callable).
      :param asc: ``True`` if order is ascending, ``False`` if descending.
      :returns: Dictionary with the sort field query.