[C++] Custom sort
Sort an array by the absolute difference of each element from the median.\n\n# Explanation\n\nUse a custom sort. The first key is |a[i] - median|, and the secon
Sort an array by the absolute difference of each element from the median.\n\n# Explanation\n\nUse a custom sort. The first key is `|a[i] - median|`, and the second key is `a[i]`. The biggest `k` elements are the strongest ones.\n\nThe time complexity is `O(n*log(n))`.\n\n# C++ Solution\n\n```cpp\nclass Solution {\npublic:\n    vector<int> getStrongest(vector<int>& arr, int k) {\n        int n = arr.size();\n        sort(arr.begin(), arr.end());\n        int median = arr[(n + 1) / 2 - 1];\n        \n        vector<pair<int, int>> a;\n        for (int i = 0; i < n; i++)\n            a.emplace_back(abs(arr[i] - median), arr[i]);\n        sort(a.begin(), a.end());\n        \n        vector<int> ans;\n        for (int i = 0; i < k; i++)\n            ans.push_back(a[n - i - 1].second);\n        \n        return ans;\n    }\n};\n```
[]