lib/heapsort.js
function buildHeap(array, heapSize, compare, swap) {
  for (var i = Math.floor(array.length / 2); i >= 0; i--) {
    heapify(array, heapSize, i, compare, swap);
  }
}
function buildHeap(array, heapSize, compare, swap) {
  for (var i = Math.floor(array.length / 2); i >= 0; i--) {
    heapify(array, heapSize, i, compare, swap);
  }
}
function buildHeap ( array , heapSize , compare , swap ) { for ( var i = Math . floor ( array . length / 2 ) ; i >= 0 ; i -- ) { heapify ( array , heapSize , i , compare , swap ) ; } }
Build a heap out of an array.
@param {Array} array The array to build a heap on.
@param {number} heapSize The size of the heap.
@param {function} compare The compare function.
@param {function} swap A function to call when the swap operation is
performed. This can be used to listen in on internals of the algorithm.
@returns The sorted array.
Build a heap out of an array .