Input:
a = [[['a','b'],3],[['b','a'],9],[['b','z'],4]]
Desired Output (dedupe regardless of order and add integers)
[[['a','b'],12],[['b','z'],4]]
This does not work of course:
a2 = [sorted(list) for list in [i[0] for i in a]]
print(a2)
[['a', 'b'], ['a', 'b'], ['b', 'z']]
which can be deduped of course:
a3= []
for i in a2:
if i not in a3:
a3.append(i)
print(a3)
[['a', 'b'], ['b', 'z']]
But of course I am losing the counts for the sub-list being deduped.
Any advice?
Thanks.