Java || Easy Approach with Explanation || HashMap || Heap( min + max )
\nclass Solution \n{//T-> O( N log N ) S->O( N )\n    public int[] frequencySort(int[] nums)\n    {\n        Map<Integer, Integer> map= new HashMap<>();//data -
```\nclass Solution \n{//T-> O( N log N ) S->O( N )\n    public int[] frequencySort(int[] nums)\n    {\n        Map<Integer, Integer> map= new HashMap<>();//data -- frequency\n        \n        for(int data: nums)//calculating and putting the frequency of data \n            map.put(data, map.getOrDefault(data, 0)+1);\n        \n        PriorityQueue<Map.Entry<Integer, Integer>> heap= new PriorityQueue<>((a, b)->{\n            return (a.getValue() == b.getValue())? b.getKey() - a.getKey() : a.getValue() - b.getValue();//maxHeap(data) (when frequency are same)//false impression tro priority Queue || minHeap(frequency)\n        });\n        \n        for(Map.Entry<Integer, Integer> entry: map.entrySet())//putting all the Entry into the heap \n            heap.offer(entry);\n        \n        int index= 0;//index is for insering into the same array\n        \n        while(heap.size() != 0)//doing the operation till the heapis Empty\n        {\n           Map.Entry<Integer, Integer> temp= heap.poll();//getting the min frequency Entry\n \n           int val= temp.getKey();//extracting the data from the Entry\n           int freq= temp.getValue();//extracting the frequency of the data from the Entry\n           \n           for(int i= 0; i< freq; i++)//overwridding the values into the Array, to reduce the space \n               nums[index+i]= val;//adding the value \n           index+= freq;//index position maintaining \n        }\n        \n        return nums;//returning the resultant array \n    }\n}//please do Upvote, it helps a lot\n```
['Heap (Priority Queue)', 'Java']