JAVA Solution Explained in HINDI
https://youtu.be/-WWyNaS1lVk\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote 
https://youtu.be/-WWyNaS1lVk\n\nFor explanation, please watch the above video and do like, share and subscribe the channel. \u2764\uFE0F Also, please do upvote the solution if you liked it.\n\n# Subscribe:- [ReelCoding](https://www.youtube.com/@reelcoding?sub_confirmation=1)\n\n## Subscribe Goal:- 600\n## Current Subscriber:- 505\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        \n        Map<Integer, Integer> freq = new HashMap<>();\n        for(int num : nums) {\n            freq.put(num, freq.getOrDefault(num, 0) + 1);\n        }\n\n        Integer[] numsObj = new Integer[nums.length];\n        for(int i = 0; i < nums.length; i++) {\n            numsObj[i] = nums[i];\n        }\n\n        Arrays.sort(numsObj, (a, b) -> {\n            if(freq.get(a).equals(freq.get(b))) {\n                return Integer.compare(b, a);\n            }\n            return Integer.compare(freq.get(a), freq.get(b));\n        });\n\n        for(int i = 0; i < nums.length; i++) {\n            nums[i] = numsObj[i];\n        }\n\n        return nums;\n    }\n}\n```
['Java']