I have a lists of lists with two elements [A,B]
. Firstly I want my heap to be defined in terms of A
but in the case A = A
I would like to compare B
in decreasing order. But heapsort understandably also compares the B
in increasing order when I want it in decreasing order, so ill get something like this
[7, 1]
[7, 0]
[6, 1]
[5, 2]
[5, 0]
[4, 4]
When I want this
[7, 0]
[7, 1]
[6, 1]
[5, 0]
[5, 2]
[4, 4]
How could I accomplish this?
For reference I'm using heapq._heapify_max
The official python solution recommends turning everything into a tuple where the first element is the one I want the sort priority on, but since I want my sort to be done on a combination of two keys this will not work