decouple from mergesort by adding comparator.