code: def prioSort(elements):
      
      # Randomize the services before sorting so that equal priority
      # elements are load-balanced.
      random.shuffle(elements)
  
      sorted_elems = sorted(elements, key=getPriority)
      return sorted_elems
docs: Sort a list of elements that have priority attributes