HeapSort with comparators and patches