I have lists :
mylist = [[3, "A", "X", "xyz", 0.93243],[43, "C", "X", "zyx", 0.23243],[13, "B", "X", "xyz", 0.43243]]
heapq.heapify(mylist)
mylist
[[3, 'A', 'X', 'xyz', 0.93243],
[43, 'C', 'X', 'zyx', 0.23243],
[13, 'B', 'X', 'xyz', 0.43243]]
When I want to pop list by using heapq.heappop(mylist)
.
First item that will be popped is [3, 'A', 'X', 'xyz', 0.93243]
. I guess, it is because the first value (3
) in the item list is the lowest.
Is it possible If I want to use the last value, index[4]
as the basis. So the popping item is based on the last element in the list?
Expected output when I want to pop item, the first item will be popped is [43, 'C', 'X', 'zyx', 0.23243]
because the index[4]
has lowest value which is 0.23243