[C++/Python] Sort
Explanation\nSort by 2 keys.\n@v_paliy note that:\n"count[x] sorts by frequency, and if two values are equal, it will sort the keys in decreasing order."\n\n\n#
## **Explanation**\nSort by 2 keys.\n@v_paliy note that:\n"count[x] sorts by frequency, and if two values are equal, it will sort the keys in decreasing order."\n<br>\n\n## **Complexity**\nTime `O(NlogN)`\nSpace `O(N)`\n<br>\n\n**C++**\n```cpp\n    vector<int> frequencySort(vector<int>& A) {\n        unordered_map<int, int> count;\n        for (int a: A)\n            count[a]++;\n        sort(begin(A), end(A), [&](int a, int b) {\n            return count[a] == count[b] ? a > b : count[a] < count[b];\n        });\n        return A;\n    }\n```\n**Python:**\n```py\n    def frequencySort(self, A):\n        count = collections.Counter(A)\n        return sorted(A, key=lambda x: (count[x], -x))\n```\n
[]