Merging sorted lists/iterators/generators into one stream of values...

Lasse Vågsæther Karlsen lasse at vkarlsen.no
Sat Oct 8 12:34:08 EDT 2005


Alex Martelli wrote:
> George Sakkis <gsakkis at rutgers.edu> wrote:
<snip>
>>Yes, it's a little inconvenient that the builtin heap doesn't take a
>>comparison operation but you can easily roll your own heap by transforming
>>each item to a (key,item) tuple. Now that I'm thinking about it, it might
>>be a good addition to the cookbook.
> 
> 
> I believe Python 2.5 adds a key= argument to heapq's functions...
<snip>

I will revisit the heapq solution when 2.5 is released then.

Thanks for the heads up. For the moment I will stay with the list 
solution that Mike came up with slightly changed to accomodate tips and 
pointers from others in this thread.

-- 
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:lasse at vkarlsen.no
PGP KeyID: 0x2A42A1C2



More information about the Python-list mailing list