sort() {
    this.maxHeapify(this.arr.length);
    let end = this.arr.length - 1;
    while (end > 0) {
      this.steps.push({action: "activate", idx: 0});
      [this.arr[0], this.arr[end]] = [this.arr[end], this.arr[0]];
      this.steps.push({action: "sort", idx: end});
      // this.steps.push({action: "dim", idx: [0]});
      end--;
      this.siftDown(0, end);
    }
    this.steps.push({action: "sort", idx: end});
  }
/**
   * Sort this.arr inplace: the array is devided into 2 parts:
   * 1. arr[0, size] (exclusive on the right), a max heap, and
   * 2. arr[size, arr.length], the sorted array.
   * Initially size = arr.length so the heap contains all elements, and no element
   * is sorted. The maximun element in the heap is extracted and pushed into the
   * sorted part each iteration. 
   */
Sort this.arr inplace: the array is devided into 2 parts:
1. arr[0, size] (exclusive on the right), a max heap, and
2. arr[size, arr.length], the sorted array.
Initially size = arr.length so the heap contains all elements, and no element
is sorted. The maximun element in the heap is extracted and pushed into the
sorted part each iteration.
Sort this . arr inplace : the array is devided into 2 parts : 1 . arr [ 0 size ] ( exclusive on the right ) a max heap and 2 . arr [ size arr . length ] the sorted array . Initially size = arr . length so the heap contains all elements and no element is sorted . The maximun element in the heap is extracted and pushed into the sorted part each iteration .
sort() {
    this.maxHeapify(this.arr.length);
    let end = this.arr.length - 1;
    while (end > 0) {
      this.steps.push({action: "activate", idx: 0});
      [this.arr[0], this.arr[end]] = [this.arr[end], this.arr[0]];
      this.steps.push({action: "sort", idx: end});
      end--;
      this.siftDown(0, end);
    }
    this.steps.push({action: "sort", idx: end});
  }
sort ( ) { this . maxHeapify ( this . arr . length ) ; let end = this . arr . length - 1 ; while ( end > 0 ) { this . steps . push ( { action : "activate" , idx : 0 } ) ; [ this . arr [ 0 ] , this . arr [ end ] ] = [ this . arr [ end ] , this . arr [ 0 ] ] ; this . steps . push ( { action : "sort" , idx : end } ) ; end -- ; this . siftDown ( 0 , end ) ; } this . steps . push ( { action : "sort" , idx : end } ) ; }
Sort this.arr inplace: the array is devided into 2 parts:
 1. arr[0, size] (exclusive on the right), a max heap, and
 2. arr[size, arr.length], the sorted array.
Sort this . arr inplace : the array is devided into 2 parts : 1 . arr [ 0 size ] ( exclusive on the right ) a max heap and 2 . arr [ size arr . length ] the sorted array .
// this.steps.push({action: "dim", idx: [0]});