Say I have the following two lists of tuples
myList = [(1, 7), (3, 3), (5, 9)] otherList = [(2, 4), (3, 5), (5, 2), (7, 8)] returns => [(1, 7), (2, 4), (3, 8), (5, 11), (7, 8)]
I would like to create a merge operation that combines the two lists, checking for any intersections of the first element of the tuple, if there are intersections, add the second element of each corresponding set (merge two). After the operation, I would like to sort by the first element.
I also post this because I think this is a fairly common problem that has an obvious solution, but I feel that there can be very pythonic solutions to this question;)
jab
source share