Suppose I have several lists of pairs (int, str), not necessarily the same length. The only limitation here is that lists are sorted in ascending order by their integer parts:
a = [(1, 'a'), (4, 'a'), (6, 'b'), (7, 'c'), (12, 'a')] b = [(5, 'd'), (10, 'c'), (11,'e')] c = [(0, 'b'), (3, 'd')]
What I would like to do is to emit the elements of the string in the order in which their corresponding integer elements meet, i.e. in this case:
(0, 'b'), (1, 'a'), (3, 'd'), (4, 'a'), ...
I am wondering if there is an obvious (good + pythonic) way to do this, simply by using iterators a , b and c ? I looked at itertools but cannot immediately see how to use the functionality in this case. Lists a , b , c can be very large, so I would like to do this without reading them in memory, and then sorting ...