code: function _MinHeap(elements) {
                      var comparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultComparator;
  
                      _classCallCheck(this, _MinHeap);
  
                      __assertArray(elements);
                      __assertFunction(comparator);
                      // we do not wrap elements here since the heapify function does that the moment it encounters elements
                      this.__elements = elements;
                      // create comparator that works on heap elements (it also ensures equal elements remain in original order)
                      this.__comparator = function (a, b) {
                          var res = comparator(a.__value, b.__value);
                          if (res !== 0) {
                              return res;
                          }
                          return defaultComparator(a.__index, b.__index);
                      };
                      // create heap ordering
                      this.__createHeap(this.__elements, this.__comparator);
                  }
docs: Creates the heap from the array of elements with the given comparator function.
  
  @param elements Array with elements to create the heap from. Will be modified in place for heap logic.
  @param comparator Comparator function (same as the one for Array.sort()).