c 2b 2b sort numbers by magnitude 2fabsolute value

Solutions on MaxInterview for c 2b 2b sort numbers by magnitude 2fabsolute value by the best coders in the world

showing results for - "c 2b 2b sort numbers by magnitude 2fabsolute value"
Théophile
09 Apr 2018
1// sort numbers by their magnitude value
2bool sortByAbsolute(int a, int b) {
3    return abs(a) < abs(b);
4}
5
6void find(std::vector<int> &nums, std::vector<int> &sorted) {
7    std::sort(nums.begin(), nums.end(), sortByAbsolute);
8}
similar questions