'Returns a SortedDict of ordering field column numbers and asc/desc'

def get_ordering_field_columns(self):

    ordering = self._get_default_ordering()
    ordering_fields = SortedDict()
    if (ORDER_VAR not in self.params):
        for field in ordering:
            if field.startswith('-'):
                field = field[1:]
                order_type = 'desc'
            else:
                order_type = 'asc'
            for (index, attr) in enumerate(self.list_display):
                if (self.get_ordering_field(attr) == field):
                    ordering_fields[index] = order_type
                    break
    else:
        for p in self.params[ORDER_VAR].split('.'):
            (none, pfx, idx) = p.rpartition('-')
            try:
                idx = int(idx)
            except ValueError:
                continue
            ordering_fields[idx] = ('desc' if (pfx == '-') else 'asc')
    return ordering_fields
