vit*_*aut 16
std::sort不保留等效元素的顺序std::stable_sort.但是,如果是ints,除非你使用一些非平凡的排序,否则你不会注意到差异,如下例所示:
struct half_less
{
bool operator()(int a, int b) const { return (a / 2) < (b / 2); }
};
std::sort(begin, end, half_less());
Run Code Online (Sandbox Code Playgroud)