<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_query(self, query, sort_info):
 """Sort query according to jsonapi 1.0 :param Query query: sqlalchemy query to sort :param list sort_info: sort information :return Query: the sorted query """

        for sort_opt in sort_info:
            field = sort_opt['field']
            if not hasattr(self.model, field):
                raise InvalidSort("{} has no attribute {}".format(self.model.__name__, field))
            query = query.order_by(getattr(getattr(self.model, field), sort_opt['order'])())
        return query