<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sort_field(self, field_name, direction, field_vals=None):
 """ sort this query by field_name in directrion field_name -- string -- the field to sort on direction -- integer -- negative for DESC, positive for ASC field_vals -- list -- the order the rows should be returned in """

        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