get_item = operator.itemgetter(some_index)
new_list = [list(g) for k, g in itertools.groupby(sorted(old_list, key=
    get_item), get_item)]
How to group a list of tuples/objects by similar index/attribute in python?