refactor C1Q1 by replacing qsort with std::sort