replace qsort with std::sort