def METHOD_NAME(self, query, sort):
    if not sort:
        # Don't sort on export
        query = query.set_sorting_block(['_doc'])
        return query
    num_sort_columns = int(self.request.GET.get('iSortingCols', 0))
    for col_num in range(num_sort_columns):
        descending = self.request.GET['sSortDir_{}'.format(col_num)] == 'desc'
        column_id = int(self.request.GET["iSortCol_{}".format(col_num)])
        column = self.headers.header[column_id]
        try:
            special_property = SPECIAL_CASE_PROPERTIES_MAP[column.prop_name]
            query = query.sort(special_property.sort_property, desc=descending)
        except KeyError:
            query = query.sort_by_case_property(column.prop_name, desc=descending)
    return query