code: function sort(array, compare, swap) {
    var heapSize = array.length;
    buildHeap(array, heapSize, compare, swap);
    while (heapSize > 1) {
      swap(array, 0, --heapSize);
      heapify(array, heapSize, 0, compare, swap);
    }
    return array;
  }
docs: Sorts an array using heapsort.
  @param {Array} array The array to sort.
  @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.