heap,heapsort,min-heap,max-heap

Just flip the sign of all your values before you put them into the heap, and again as you take them out of the heap.

python,insert,heap,priority-queue,max-heap

Your problem seems to be in your enqueue. def enqueue(self, item, priority): self.PQ.insert(item) The priority parameter is not used at all. Instead, your heap is using string comparisons. This is the state of your heap before any dequeue: [None, 'Yamagata', 'Tetsuo', 'Shikishima', 'Takashi', 'Masaru', 'Akira', 'Kiyoko', 'Kei', 'Kaneda'] ...