Javascript Solution
\n/**\n * Time Complexity: O(nlogn)\n * Space Complexity: O(n)\n * @param {number[]} nums\n * @return {number[]}\n */\nconst frequencySort = function (nums) {  
```\n/**\n * Time Complexity: O(nlogn)\n * Space Complexity: O(n)\n * @param {number[]} nums\n * @return {number[]}\n */\nconst frequencySort = function (nums) {   \n  return nums.sort(compareFrequency(mapFrequency(nums)));\n};\n\n/**\n * @param {number[]} nums\n * @return {number{}}\n */\nconst mapFrequency = function (nums) {\n  return nums.reduce(\n    (acc, cur) => (acc[cur] = (acc[cur] || 0) + 1, acc)\n  , {}); \n}\n\n/**\n * @param {number{}} frequency\n * @return {number}\n */\nconst compareFrequency = function (frequency) {\n  return function (a, b) {\n    return (frequency[a] - frequency[b]) || b - a;\n  }\n}\n\n```
['JavaScript']