How would I write the following Java PriorityQueue in Python?
PriorityQueue<Integer[]> pq = new PriorityQueue<Integer[]>(11,
new Comparator<Integer[]>() {
public int compare(Integer[] A, Integer[] B) {
return A[0] < B[0] ? -1 : 1;
}
});
I got as far as
from Queue import PriorityQueue
def my_method(self):
pq = # I got stuck here since I need to include "comparator"
I have looked through many examples such as Creating a python priority Queue but they don't seem to be defining a priorty function
or comparator
of some sort.