[issue40239] Add a function for merging sorted iterables

2020-04-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you Tim, it is exactly what I need! I got this search result, but I rejected it because it looked obvious that the function from the heapq module cannot have any relation to this. :( I meant chain() instead of tee(), sorry. -- resolution: -

[issue40239] Add a function for merging sorted iterables

2020-04-09 Thread Tim Peters
Tim Peters added the comment: Serhiy, are you aware of heapq.merge()? If not, look it up. And then if you still think merge_sorted() would differ in some way, please spell out how it would differ. Based on what you wrote, you threw an invalid invocation of tee() into the mix for some reas

[issue40239] Add a function for merging sorted iterables

2020-04-09 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi Serhiy, do you plan on writing a PR for this feature? If not I would love to have a go at it. -- nosy: +remi.lapeyre ___ Python tracker ___

[issue40239] Add a function for merging sorted iterables

2020-04-09 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : It would be useful to have a function in itertools to merge sorted iterables. merge_sorted(*iterables, key=None, reverse=False): It should emit the same items as sorted(tee(*iterables), key=key, reverse=reverse) if iterables are sorted with key and r