I have two lists of tuples:
I want to combine them depending on their name which is the first value of each tuple in each set. The lists are not sorted by name. The result shall look like:
Is there any more effective solution than iterating with two pointers?
sorted_a = sorted(a, key=lambda x: x) sorted_b = sorted(b, key=lambda x: x) combined = [(sorted_a[idx], sorted_a[idx], sorted_b[idx]) for idx in range(len(a))]