the proper ordering of items with equal prioritythe enqueue operation must ensure newer items are inserted closer to the front of the list than the other items with the same priority an implementation of the priority queue using python list in which new items are appended to the end is provided in listing sample instance of the class is illustrated in figure note this implementation does not use the numlevels argument passed to the constructor since we can store items having any number of priority levels listing the priorityq py module implementation of the unbounded priority queue adt using python list with new items appended to the end class priorityqueue create an empty unbounded priority queue def __init__self )self _qlist list(returns true if the queue is empty def isemptyself )return lenself = returns the number of items in the queue def __len__self )return lenself _qlist adds the given item to the queue def enqueueselfitempriority )create new instance of the storage class and append it to the list entry _priorityqentryitempriority self _qlist appendentry removes and returns the first item in the queue def dequeueself assert not self isempty()"cannot dequeue from an empty queue find the entry with the highest priority highest self _qlist[ipriority for in rangeself len(see if the ith entry contains higher priority (smaller integerif self _qlist[ipriority highest highest self _qlist[ipriority remove the entry with the highest priority and return the item entry self _qlist pophighest return entry item private storage class for associating queue items with their priority class _priorityqentryobject )def __init__selfitemprioity )self item item self priority priority