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