std::sort ( , ), , , ( ) .
std::sort : operator<, /. :— , <, /.
?
, . , operator<, , , . , .
, . , operator< . , , : , ; ( ), ; , , , , , .
, , int :
std::vector<int> v{10, 3, 12, -26};
std::sort(v.begin(), v.end());
print(v);
: -26,3,10,12. operator< .
, , (, ), :
std::vector<int> v{10, 3, 12, -26};
auto abs_cmp = [](int a, int b) { return std::abs(a) < std::abs(b); };
std::sort(v.begin(), v.end(), abs_cmp);
print(v);
: 3,10,12,-26. , .
, .