code: function siftDown(arr, comp, pos, end, sym) {
    if (!isNumber(end)) {
      sym = end;
      end = arr.length;
    }
    let largest;
    const left = 2 * pos + 1,
          right = 2 * pos + 2;
    if (left < end && comp(arr[left], arr[pos]) > 0) {
      largest = left;
    } else {
      largest = pos;
    }
  
    if (right < end && comp(arr[right], arr[largest]) > 0) {
      largest = right;
    }
  
    if (largest === pos) {
      updateIndexAt(arr, pos, sym);
      return arr;
    } else {
      const tmp = arr[pos];
      arr[pos] = arr[largest];
      arr[largest] = tmp;
      updateIndexAt(arr, pos, sym);
      updateIndexAt(arr, largest, sym);
      return siftDown(arr, comp, largest, end, sym);
    }
  }
docs: O(log(n))