class PriorityQueue(object):
    def __init__(self):
        self.qlist = []
    def __len__(self):
        return len(self.qlist)
    def isEmpty(self):
        return len(self) == 0
    def enqueue(self, data, priority):
        entry = PriorityQEntry(data, priority)
        self.qlist.append(entry)
    def dequeue(self):
        A = []
        for i in self.qlist:
            A.append(i)
        s = 0
        for i in range(1, len(self.qlist)):
            if A[i].priority < A[s].priority:
                s = i
        hasil = self.qlist.pop(s)
        return hasil.item

class PriorityQEntry(object):
    def __init__ (self,data,priority):
        self.item = data
        self.priority = priority

t = PriorityQueue()
t.enqueue("mangga",4)
t.enqueue("anggur",3)
t.enqueue("jeruk",7)
t.enqueue("sawo", 2)
t.enqueue("pepaya", 6)
print (t.dequeue())
print (t.dequeue())
print (t.dequeue())
print (t.dequeue())
print (t.dequeue())

