code: function buildHeap(array, heapSize, compare, swap) {
    for (var i = Math.floor(array.length / 2); i >= 0; i--) {
      heapify(array, heapSize, i, compare, swap);
    }
  }
docs: 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.