sortHeap

Sorts buf as a heap using the supplied predicate or '<' if none is supplied. Calling makeHeap and sortHeap on an array in succession has the effect of sorting the array using the heapsort algorithm.

  1. void sortHeap(Elem[] buf, Pred2E pred)
    version(TangoDoc)
    void
    sortHeap
  2. template sortHeap(Buf)
  3. template sortHeap(Buf, Pred)

Parameters

buf Elem[]

The heap to sort. This parameter is not marked 'ref' to allow temporary slices to be sorted. As buf is not resized in any way, omitting the 'ref' qualifier has no effect on the result of this operation, even though it may be viewed as a side-effect.

pred Pred2E

The evaluation predicate, which should return true if e1 is less than e2 and false if not. This predicate may be any callable type.

Meta