I use heapq module in python, I find I only can the min heap, even if I use reverse=True
I still get the min top heap
from heapq import *
h=[]
merge(h,key=lambda e:e[0],reverse=True)
heappush(h, (200, 1))
heappush(h, (300,2))
heappush(h, (400,3))
print(heappop(h))
I still get the result:
(200, 1)
I want to get result:
(400,3)
how to do it?
which is the smallest element. I want pop the largest emelment?
ps: this is part of question find the max and then divide into several elements and then put it back to the heap.