c++ sort

排序

sort(nums.begin(),nums.end(),std::less<int>()); // 从小到大
sort(nums.begin(),nums.end(),std::greater<int>()); //从大到小

is_sorted(nums.begin(),nums.end(),std::less<int>()); // 从小到大
is_sorted(nums.begin(),nums.end(),std::greater<int>()); // 从大到小

猜你喜欢

转载自www.cnblogs.com/wei-huan/p/10065752.html