class sortedpriorityqueue(priorityqueuebase)base class defines item """ min-oriented priority queue implemented with sorted list "" def init (self) """create new empty priority queue "" self data positionallist def len (self) """return the number of items in the priority queue "" return len(self data def add(selfkeyvalue) """add key-value pair ""make new item instance newest self item(keyvaluewalk backward looking for smaller key walk self data last while walk is not none and newest walk element) walk self data before(walk if walk is nonenew key is smallest self data add first(newest elsenewest goes after walk self data add after(walknewest def min(self) """return but do not remove ( ,vtuple with minimum key "" if self is empty) raise emptypriority queue is empty self data first item element return (item keyitem value def remove min(self) """remove and return ( ,vtuple with minimum key "" if self is empty) raise emptypriority queue is empty item self data delete(self data first) return (item keyitem valuecode fragment an implementation of priority queue using sorted list the parent class priorityqueuebase is given in code fragment and the positionallist class is from section