(detail_columns, sort_elements)
return sort_only_elements, sort_columns
extracts out info about columns that are added as only sort fields and columns added as both
    sort and display fields
extracts out info about columns that are added as only sort fields and columns added as both
    sort and display fields
extracts out info about columns that are added as only sort fields and columns added as both sort and display fields
def get_sort_and_sort_only_columns(detail_columns, sort_elements):
    """
    extracts out info about columns that are added as only sort fields and columns added as both
    sort and display fields
    """
    sort_elements = OrderedDict((s.field, (s, i + 1)) for i, s in enumerate(sort_elements))
    sort_columns = {}
    for column in detail_columns:
        sort_element, order = sort_elements.pop(column.field, (None, None))
        if sort_element:
            sort_columns[column.field] = (sort_element, order)

    sort_only_elements = [
        SortOnlyElement(field, element, element_order)
        for field, (element, element_order) in sort_elements.items()
    ]
    return sort_only_elements, sort_columns
def get_sort_and_sort_only_columns ( detail_columns , sort_elements ) : sort_elements = OrderedDict ( ( s . field , ( s , i + 1 ) ) for i , s in enumerate ( sort_elements ) ) sort_columns = { } for column in detail_columns : sort_element , order = sort_elements . pop ( column . field , ( None , None ) ) if sort_element : sort_columns [ column . field ] = ( sort_element , order ) sort_only_elements = [ SortOnlyElement ( field , element , element_order ) for field , ( element , element_order ) in sort_elements . items ( ) ] return sort_only_elements , sort_columns