src/precore/util/Collections.php
public static function createHeap(Comparator $comparator = null) : SplHeap
    {
        if ($comparator === null) {
            $comparator = ComparableComparator::instance();
        }
        return new ComparatorBasedHeap($comparator);
    }
public static function createHeap(Comparator $comparator = null) : SplHeap
    {
        if ($comparator === null) {
            $comparator = ComparableComparator::instance();
        }
        return new ComparatorBasedHeap($comparator);
    }
Creates an {@link SplHeap} based on the given comparator object.
All elements in the heap must be mutually comparable using the specified comparator
(that is, c.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the heap).

<p>
If the specified comparator is null, all elements in the heap must implement
the {@link Comparable} interface. Furthermore, all elements in the heap must be mutually comparable
(that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the heap).

@param Comparator $comparator
@return SplHeap