- pyf.dataflow.merging.merge_iterators(iterators, key=None)¶
Merge multiple sorted inputs into a sorted output of grouped items according to key (while there is at least one of the iterators that still have values).
- The iterators must be sorted by key
- Only one item is supported by unique key in each iterator. If you have more, please do groupby on key and pass that item to the merge_iterators function.
- Key should be a function: it will get applied on all iterator items to get the uniquelinking value.
- To different key getter, set key as a list: one key per iterator, in the same order.
>>> list(merge_iterators([xrange(4), xrange(1,5), [2,3]])) ... [(0, None, None), (1, 1, None), (2, 2, 2), (3, 3, 3), (None, 4, None)]