code: def sort_query(self, query, sort_info):
          
          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
docs: 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