Also, std::sort should be faster than qsort() since the comparator is usually inlined in the former v/s called via a function pointer in the latter.