A is a list or vector that supports isEmpty, removeFirst and insertLast P is a priority queue QSort(A,s) (1) while !A.isEmpty() (2) P.insertItem(A.removeFirst()) (3) while !P.isEmpty() (4) A.insertLast(P.removeMin())
bool operator <(p1, p2) { if (p1.level != p2.level) return (p1.level < p2.level) else if (p1.nice != p2.nice) return(p1.nice < p2.nice else return(p1.lastrun < p2.lastrun) }