1vector<int> v = {50, -10, 20, -30};
2
3sort(v.begin(), v.end()); // the default sort
4// now v should be { -30, -10, 20, 50 }
5
6// sort by absolute value:
7sort(v.begin(), v.end(), [](int a, int b) { return abs(a)<abs(b); });
8// now v should be { -10, 20, -30, 50 }