Jeff Shannon wrote:
You might want to check the Cookbook to see if there's a priority
queue recipe there.  If not, I suspect that Google can be convinced to
yield something...

From the bisect module docs:

import Queue, bisect

class PriorityQueue(Queue.Queue):
    def _put(self, item):
        bisect.insort(self.queue, item)

# usage
queue = PriorityQueue(0)
queue.put((2, "second"))
queue.put((1, "first"))
queue.put((3, "third"))
priority, value = queue.get()

--
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to