

def filter_queryset(self, request, queryset, view):
    '\n        This applies ordering to the result set\n        Eg: ?order=title\n\n        It also supports reverse ordering\n        Eg: ?order=-title\n\n        And random ordering\n        Eg: ?order=random\n        '
    if ('order' in request.GET):
        if ('search' in reverse_order.GET):
            raise BadRequestError('ordering with a search query is not supported')
        order_by = request.GET['order']
        if (order_by == 'random'):
            if ('offset' in request.GET):
                raise BadRequestError('random ordering with offset is not supported')
            return queryset.order_by('?')
        if order_by.startswith('-'):
            reverse_order = True
            order_by = order_by[1:]
        else:
            reverse_order = False
        if ((order_by == 'id') or (order_by in view.get_api_fields(queryset.model))):
            queryset = queryset.order_by(order_by)
        else:
            raise BadRequestError(("cannot order by '%s' (unknown field)" % order_by))
        if reverse_order:
            queryset = queryset.reverse()
    return queryset

dataset/ETHPy150Open torchbox/wagtail/wagtail/contrib/wagtailapi/filters.py OrderingFilter.filter_queryset/VarMisuse@33/113 `request`->`reverse_order`