def prioSort(elements):
 random.shuffle(elements)
 prio_elems = [(getPriority(e), e) for e in elements]
 prio_elems.sort()
 sorted_elems = [s for (_, s) in prio_elems]
 return sorted_elems

def prioSort ( elements ) : random . shuffle ( elements ) prio_elems = [ ( getPriority ( e ) , e ) for e in elements ] prio_elems . sort ( ) sorted_elems = [ s for ( _ , s ) in prio_elems ] return sorted_elems
sort a list of elements that have priority attributes .