I am just learning the priority queues in Python, and I have made the following code:
def main():
q=Queue.PriorityQueue()
while True:
n=input("numbre?")
if n==0:
break
else:
q.put(n)
print n
while not q.empty():
print q.get()
when I input data like: 9, 1, 4, 5
it prints 1,4,5,9 which it seems correct, but I would like to know how can I do to deque in reverse order, I mean: 9,5,4,1
I know how to do that with a class, but in this case it seems the following extra code:
def __cmp__():
-cmp(q.get(),q.get())
does not work, any help?