Accept args to filter by in format like this:

        .. code-block:: python3

            .order_by('name', '-tournament__name')

        Supports ordering by related models too.
321875
def order_by(self, *orderings: str) -> "QuerySet":
        
        queryset = self._clone()
        new_ordering = []
        for ordering in orderings:
            order_type = Order.asc
            if ordering[0] == "-":
                field_name = ordering[1:]
                order_type = Order.desc
            else:
                field_name = ordering

            if not (
                field_name.split("__")[0] in self.model._meta.fields
                or field_name in self._annotations
            ):
                raise FieldError(
                    "Unknown field {} for model {}".format(field_name, self.model.__name__)
                )
            new_ordering.append((field_name, order_type))
        queryset._orderings = new_ordering
        return queryset
140859
def order_by(self, **kwargs):
        
        if kwargs:
            col, order = kwargs.popitem()
            self.order_clause = "order by {col} {order} ".format(
                col=col, order=order)
        return self
313894
def get_ordering(self, request, queryset, view):
        
        params = view.get_request_feature(view.SORT)
        if params:
            fields = [param.strip() for param in params]
            valid_ordering, invalid_ordering = self.remove_invalid_fields(
                queryset, fields, view
            )

            # if any of the sort fields are invalid, throw an error.
            # else return the ordering
            if invalid_ordering:
                raise ValidationError(
                    "Invalid filter field: %s" % invalid_ordering
                )
            else:
                return valid_ordering

        # No sorting was included
        return self.get_default_ordering(view)
38537
def get_order(self):
        
        # first get the filtered attributes in order as they must appear
        # in the order_by first
        if not self.has_order:
            return None
        filter_order_clauses = OrderedDict([(filter_attr[0], None)
                                            for filter_attr in self._filters
                                            if isinstance(filter_attr, tuple)])

        # any order_by attribute that appears in the filters is ignored
        order_by_dict = self._order_by.copy()
        for filter_oc in filter_order_clauses.keys():
            direction = order_by_dict.pop(filter_oc, None)
            filter_order_clauses[filter_oc] = direction

        filter_order_clauses.update(
            order_by_dict)  # append any remaining order_by clause

        if filter_order_clauses:
            return ','.join(['{} {}'.format(attribute,
                                            direction if direction else '')
                            .strip()
                             for attribute, direction in
                             filter_order_clauses.items()])
        else:
            return None
956071
def sort_model(self, *args, **kwargs):
        
        self.proxy.sort(17)  # sort the identifier
        self.proxy.sort(2)  # sort the element
        self.proxy.sort(1)  # sort the elementgrp
        self.proxy.sort(0)
390424
def _order_by_pks(qs, pks):
    
    pk_colname = '%s.%s' % (
        qs.model._meta.db_table, qs.model._meta.pk.column)
    clauses = ' '.join(
        ['WHEN %s=%s THEN %s' % (pk_colname, pk, i)
            for i, pk in enumerate(pks)]
    )
    ordering = 'CASE %s END' % clauses
    return qs.extra(
        select={'pk_ordering': ordering}, order_by=('pk_ordering',))
1093678
def order_by(self, field_name=None):
        
        assert self.query.can_filter(), "Cannot reorder a query once a slice has been taken."

        clone = self._clone()
        clone.query.clear_ordering()

        if field_name is not None:
            clone.query.add_ordering(field_name)

        return clone
101404
def queryset(self, request, **kwargs):
        
        qs = self.model._default_manager.all()
        if self.ordering:
            qs = qs.order_by(*self.ordering)
        return qs
152134
def order(*args)
      options = args.extract_options!
      if options.empty? && args.count == 1
        __new_relation__(all.sort_by { |item| item.send(args.first) })
      else
        __new_relation__(Sort.order_mixed_args(all, args, options))
      end
    end
1294359
def filter(self, **kwargs):
        
        readFilter = ReadFilter(**kwargs)
        self._filters.append(readFilter.filter)
        return self
1680
def filter_by(self, **kwargs):
        
        query = self._copy()
        for field, value in kwargs.items():
            query.domain.append(
                (field, '=', value)
            )
        return query
615723
def _filter_parameters(parameters):
    """"""
    if not parameters:
        return None
    return OrderedDict(
        (param, value) for param, value in six.iteritems(parameters) if param not in IGNORED_PARAMS
    )
524735
def order_by(self, *args):
        
        if self._solr_locked:
            raise Exception("Query already executed, no changes can be made."
                            "%s %s" % (self._solr_query, self._solr_params)
                            )

        for arg in args:
            if arg.startswith('-'):
                self._solr_params['sort'][arg[1:]] = 'desc'
            else:
                self._solr_params['sort'][arg] = 'asc'
813802
def query_model(self, model, condition=None, offset=None, limit=None,
                    order_by=None, group_by=None, having=None, fields=None):
        
        from uliweb import settings, request
        from uliweb.utils.common import log
        from uliweb.orm import rawsql
        
        if self._query is not None:
            query = self._query
            if condition is not None and isinstance(query, Result):
                query = query.filter(condition)
        else:
            query = self.model.filter(condition)

        if request.GET.get('_debug_'):
            log.info(rawsql(query.get_query()))
        
        if self.pagination:
            if offset is not None:
                query = query.offset(int(offset))
            if limit is not None:
                query = query.limit(int(limit))
        if order_by is not None:
            if isinstance(order_by, (tuple, list)):
                query = query.order_by(*order_by)
            else:
                query = query.order_by(order_by)
        if group_by is not None:
            if isinstance(group_by, (tuple, list)):
                query = query.group_by(*group_by)
            else:
                query = query.group_by(group_by)
            if having is not None:
                query = query.having(having)
        return query
239173
def filter(self, *args, **kwargs) -> "QuerySet":
        
        return self._filter_or_exclude(negate=False, *args, **kwargs)
1219809
def order_by_raw(self, sql, bindings=None):
        
        if bindings is None:
            bindings = []

        type = "raw"

        self.orders.append({"type": type, "sql": sql})

        self.add_binding(bindings, "order")

        return self
1144984
def filter(self, *args):
        

        def wraps(f):
            self.add_filter(func=f, rules=list(args))
            return f

        return wraps