def sort(self, queryset):
        fields = []
        db, virtual = self.get_ordering_splits()
        for name in db:
            sort_direction = ''
            if name[0] in '+-':
                sort_direction = name[0]
                if sort_direction == '+':
                    sort_direction = ''
                name = name[1:]
            column = self.columns[name]
            sources = column.get_sort_fields(self.model)
            if sources:
                fields.extend([(sort_direction + source) for source in sources])

        object_list = queryset.order_by(*fields)

        # When sorting a plural relationship field, we get duplicate rows for each item on the other
        # end of that relationship, which can't be removed with a call to distinct().
        if self._force_distinct and contains_plural_field(self.model, fields):
            object_list = self.force_distinct(object_list)

        if virtual:
            # Have to sort the whole queryset by hand!
            object_list = list(object_list)

            for name in virtual[::-1]:  # stable sorting, top priority sort comes last
                reverse = False
                if name[0] in '+-':
                    reverse = (name[0] == '-')
                    name = name[1:]
                column = self.columns[name]
                object_list.sort(key=lambda o: column.value(o)[0], reverse=reverse)

        return object_list
Override for custom error page.
dataset/ETHPy150Open pivotal-energy-solutions/django-datatable-view/datatableview/datatables.py/Datatable.sort--crossover with--dataset/ETHPy150Open dropbox/grouper/grouper/fe/util.py/GrouperHandler.write_error