Comparator implemented on heapsort