class - Python Priority Queue, insertion of elements -


i making class priority queue. queue contains of list paired tuples:

[("do homework", 1), ("clean room", 2)] 

and trying make function inside class insert element (tuple) in queue (list). if inserted tuple has higher priority (greater number right) 1 in queue, tuple higher priority inserted before tuple lower.

so correct order be:

[("make food", 4), ("clean room", 2),("do homework", 1)] 

i think have kind of sorting function , have started make 1 stuck.

self.item = []  def enqueue(self, a, b):     el in self.item:         if self.item.empty():             return self.item.insert(0, (a, b))         else:             tupl in el:                 if tupl[1] > tupl+1[1]: 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -