I am confused in heap pop output.
import heapq
heapq.heappush(PQ, ['b', 0.95])
heapq.heappush(PQ, ['d', 0.72])
heapq.heappush(PQ, ['e', 1.75])
a = heapq.heappop(PQ)
print (a)
It returns : ['b', 0.95] Why it's not returning ['d', 0.72]
import heapq
PQ = []
heapq.heappush(PQ, ['z', 0.95]) # Changed it to z which is bigger
heapq.heappush(PQ, ['d', 0.72])
heapq.heappush(PQ, ['e', 1.75])
a = heapq.heappop(PQ)
print (a)
The result is ['d', 0.72]. The first element is used to sort min-heap.