code: def sort_field(self, field_name, direction, field_vals=None):
          field_name = self._normalize_field_name(field_name)
          if direction > 0:
              direction = 1
          elif direction < 0:
              direction = -1
          else:
              raise ValueError("direction {} is undefined".format(direction))
          self.fields_sort.append(field_name, [direction, field_name, list(field_vals) if field_vals else field_vals])
          return self