f | def joinseq(*seq): | f | def joinseq(*seq): |
n | iterators = [iter(seq_) for seq_ in seq] | n | iterators = [iter(sequence) for sequence in seq] |
| val = [next(i) for i in iterators] | | value = [next(i) for i in iterators] |
| while True: | | while True: |
n | min_item = min(val) | n | min_item = min(value) |
| yield min_item | | yield min_item |
t | idx = val.index(min_item) | t | index = value.index(min_item) |
| val[idx] = next(iterators[idx], None) | | value[index] = next(iterators[index], None) |
| if val[idx] == None: | | if value[index] == None: |
| val.pop(idx) | | value.pop(index) |
| iterators.pop(idx) | | iterators.pop(index) |
| if val == []: | | if value == []: |
| break | | break |