On Mar 29, 8:36 am, "Apollo" <tju...@qq.com> wrote: > as we all known, in the standard module 'heapq', we can easily get the > smallest item from the heap. i.e. it's an implementation of min-heap. > > my question is how to use 'heapq' to extract the biggest item from the heap? > is it possible? > > thanks in advance.:)
If heapifying something that will be compared by number, then use the negative of the number in the object to be heapified. You can then negate it when popped. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list