This method sorts the tasks by highest priority first.
517469
public function sortByPriority(GrumPHP $grumPHP): self
    {
        $priorityQueue = new SplPriorityQueue();
        $stableSortIndex = PHP_INT_MAX;
        foreach ($this->getIterator() as $task) {
            $metadata = $grumPHP->getTaskMetadata($task->getName());
            $priorityQueue->insert($task, [$metadata['priority'], $stableSortIndex--]);
        }

        return new self(array_values(iterator_to_array($priorityQueue)));
    }
1031048
public void sort() {
        PriorityQueue<Op.Pair<Term, Double>> termCentroids
                = new PriorityQueue<Op.Pair<Term, Double>>(
                        terms.size(), new Ascending());
        Defuzzifier defuzzifier = new Centroid();
        for (Term term : terms) {
            double centroid;
            try {
                if (term instanceof Constant || term instanceof Linear) {
                    centroid = term.membership(0);
                } else {
                    centroid = defuzzifier.defuzzify(term, getMinimum(), getMaximum());
                }
            } catch (Exception ex) {
                centroid = Double.POSITIVE_INFINITY;
            }
            termCentroids.offer(new Op.Pair<Term, Double>(term, centroid));
        }

        List<Term> sortedTerms = new ArrayList<Term>(terms.size());
        while (!termCentroids.isEmpty()) {
            sortedTerms.add(termCentroids.poll().getFirst());
        }
        setTerms(sortedTerms);
    }
136603
private void processPredecessors(Gantt gantt)
   {
      for (Gantt.Tasks.Task ganttTask : gantt.getTasks().getTask())
      {
         String predecessors = ganttTask.getP();
         if (predecessors != null && !predecessors.isEmpty())
         {
            String wbs = ganttTask.getID();
            Task task = m_taskMap.get(wbs);
            for (String predecessor : predecessors.split(";"))
            {
               Task predecessorTask = m_projectFile.getTaskByID(Integer.valueOf(predecessor));
               task.addPredecessor(predecessorTask, RelationType.FINISH_START, ganttTask.getL());
            }
         }
      }
   }
735882
@SuppressWarnings("checkstyle:MissingSwitchDefault")
    private PriorityQueue<CrawlCandidate> createPriorityQueue() {
        Function crawlDepthGetter
                = (Function<CrawlCandidate, Integer> & Serializable) CrawlCandidate::getCrawlDepth;
        Function priorityGetter
                = (Function<CrawlCandidate, Integer> & Serializable) CrawlCandidate::getPriority;

        switch (config.getCrawlStrategy()) {
            case BREADTH_FIRST:
                Comparator breadthFirstComparator = Comparator.comparing(crawlDepthGetter)
                        .thenComparing(priorityGetter, Comparator.reverseOrder());

                return new PriorityQueue<>(breadthFirstComparator);
            case DEPTH_FIRST:
                Comparator depthFirstComparator
                        = Comparator.comparing(crawlDepthGetter, Comparator.reverseOrder())
                                .thenComparing(priorityGetter, Comparator.reverseOrder());

                return new PriorityQueue<>(depthFirstComparator);
        }

        throw new IllegalArgumentException("Unsupported crawl strategy.");
    }
137152
def __sort_up(self):

        """"""
        if self.__do_need_sort_up:
            self.__up_objects.sort(key=cmp_to_key(self.__up_cmp))
            self.__do_need_sort_up = False
268851
public Priority[] filePriorities() {
        int_vector v = th.get_file_priorities2();
        int size = (int) v.size();
        Priority[] arr = new Priority[size];
        for (int i = 0; i < size; i++) {
            arr[i] = Priority.fromSwig(v.get(i));
        }
        return arr;
    }
484971
public void order() {
        Collections.sort(cells, new Comparator<SortedSet<Integer>>() {

            @Override
            public int compare(SortedSet<Integer> cellA, SortedSet<Integer> cellB) {
                return cellA.first().compareTo(cellB.first());
            }

        });
    }
213546
protected void sortPreparePriorityResources() {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "sortPreparePriorityResources", _resourceObjects.toArray());

        Collections.sort(_resourceObjects, prepareComparator);

        if (tc.isEntryEnabled())
            Tr.exit(tc, "sortPreparePriorityResources", _resourceObjects.toArray());
        return;
    }
967744
public static <T> ArrayList<T> sortThis(ArrayList<T> list, Comparator<? super T> comparator)
    {
        int size = list.size();
        if (ArrayListIterate.canAccessInternalArray(list))
        {
            Arrays.sort(ArrayListIterate.getInternalArray(list), 0, size, comparator);
        }
        else
        {
            Collections.sort(list, comparator);
        }
        return list;
    }
1241126
def get_top_priority(self):
        
        if self.is_empty():
            raise IndexError("Priority queue is empty.")
        _, _, element = heapq.heappop(self.pq)
        if element in self.element_finder:
            del self.element_finder[element]
        return element
1121569
public void keepTopNElements(int N){
        PriorityQueue<Pair<T, Double>> queue = asPriorityQueue();
        clear();
        for (int e = 0; e < N; e++) {
            Pair<T, Double> pair = queue.poll();
            if (pair != null)
                incrementCount(pair.getFirst(), pair.getSecond());
        }
    }
1012875
private void prioritizeFromEntryNode(DiGraphNode<Node, Branch> entry) {
    PriorityQueue<DiGraphNode<Node, Branch>> worklist =
        new PriorityQueue<>(10, priorityComparator);
    worklist.add(entry);

    while (!worklist.isEmpty()) {
      DiGraphNode<Node, Branch> current = worklist.remove();
      if (nodePriorities.containsKey(current)) {
        continue;
      }

      nodePriorities.put(current, ++priorityCounter);

      List<DiGraphNode<Node, Branch>> successors = cfg.getDirectedSuccNodes(current);
      worklist.addAll(successors);
    }
  }
41266
public static final <T> void quickSort(List<T> list, Comparator<T> comparator)
    {
        quickSort(list, 0, list.size()-1, comparator);
    }
32475
private void moveRowsBasedOnPriority() {
        for (RowNumber myNumber : overs.keySet()) {
            Over over = overs.get(myNumber);

            int newIndex = rowOrder.indexOf(new RowNumber(over.getOver()));

            rowOrder.remove(myNumber);
            rowOrder.add(newIndex,
                         myNumber);
        }
    }
1323501
public void processQueue(
      Predicate<RequestHandler> handlerConsumer,
      Prioritizer prioritizer) {

    Comparator<RequestHandler> comparator =
        prioritizer == null ?
        Ordering.allEqual()::compare :
        (a, b) -> prioritizer.compareTo(
            a.getRequest().getDesiredCapabilities(), b.getRequest().getDesiredCapabilities());

    lock.writeLock().lock();
    try {

      newSessionRequests.stream()
          .sorted(comparator)
          .filter(handlerConsumer)
          .forEach(requestHandler -> {
            if (!removeNewSessionRequest(requestHandler)) {
              log.severe("Bug removing request " + requestHandler);
            }
          });
    } finally {
      lock.writeLock().unlock();
    }
  }
391083
public static void sortDescending(int[] intArray) {
        boolean swapped = true;
        
        while(swapped) {
            swapped = false;
            
            for(int i = 0; i < (intArray.length - 1 ); i++) {
                if(intArray[i] < intArray[i + 1]) {
                    TrivialSwap.swap(intArray, i, i + 1);
                    
                    swapped = true;
                }
            }            
        }
    }
1158160
def _sort(self):
        
        self._log.debug('Sorting responses by priority')
        self._responses = OrderedDict(sorted(list(self._responses.items()), reverse=True))
        self.sorted = True