I am new to Python and so far I know that tuples can be sorted and it is the first value of the tuple that is used for sorting.
So, here is where I am not sure how minheap maintains the heap invariant when the nodes are a tuple of integers.
For e.g. I pushed some tuples and my heap looks like this [(1, -1), (2, -2), (2, -3)]
I do a heappop for each of these tuple starting with (1, -1) so after the heap invariant is maintained, the heap looks like this [(2, -3), (2, -2)] and then again after a pop it looks like [(2, -2)]
This shows that the min element at the root is selected based on the second element of the Tuple (and not the first).
Is my observation correct? Does this mean that when the first element of the Tuples is same in the heap left after a pop, the heap invariant is maintained by selecting the second element of the Tuple?
Can the python experts weigh in?