java easy to understand solution
-> The idea is to use hashmap for storing frequency of the values and then iterate over hashmap and store values and their frequency in 2d array then sort the 2
-> The idea is to use hashmap for storing frequency of the values and then iterate over hashmap and store values and their frequency in 2d array then sort the 2d array on the basis of two columns and then fill the new ans[] array and return it.\n-> We will sort the array on the basis of two columns because values having equal frequencies should be sorted in decreasing order.\n-> So, we will first sort the 2d array on the basis of values (decreasing order) and then on the basis of frequency (increasing order).\n******Please Please...... upvote if it helps you to solve the problem******* as it motivates me to post solutions.\n    \n\tpublic int[] frequencySort(int[] nums) {\n\t\t //hashmap for storing frequency of the values\n        HashMap<Integer,Integer> hm = new HashMap<>();\n        \n\t\tint c = 0; //for counting distinct values \n        for(int i=0;i<nums.length;i++){\n            if(hm.containsKey(nums[i])){\n                int v = hm.get(nums[i]);\n                v++;\n                hm.put(nums[i],v);\n            }else{\n                hm.put(nums[i],1);\n                c++;\n            }\n        }\n\t\t\n        int[][] arr = new int[c][2];  //2d array which contains values in first column and frequency in second column\n\t\t\n\t\t//iterate over hashmap to store value and frequency in 2d array\n        int i=0;\n\t\tfor(Map.Entry<Integer,Integer> entry:hm.entrySet()){\n            arr[i][0] = entry.getKey();\n            arr[i][1] = entry.getValue();\n            i++;\n        }\n\t\t// values are sorted in decreasing order as per given in the question\n        Arrays.sort(arr,(a,b)->b[0]-a[0]);\n\t\t\n\t\t//frequency in increasing order\n        Arrays.sort(arr,(a,b)->a[1]-b[1]);  \n        \n\t\tint[] ans = new int[nums.length];  //ans array to return the answer\n        int j=0;\n        for(i=0;i<arr.length;i++){\n            int count = 0;\n            while(count<arr[i][1]){\n                ans[j] = arr[i][0];\n                j++;\n                count++;\n            }\n        }\n        return ans;\n    }\n\t}```
['Array', 'Hash Table', 'Sorting', 'Java']