Simple Solution in Java
Use map to store element & count/frequency\n- Use priority queue to store key-value pair is custom sorted format (as required in question)\n- Store the elements
- Use map to store element & count/frequency\n- Use priority queue to store key-value pair is custom sorted format (as required in question)\n- Store the elements as required in array\n\n```\nclass Solution {\n    public int[] frequencySort(int[] nums) {\n        Map<Integer,Integer> map=new HashMap<>();\n        PriorityQueue<int[]> pq=new PriorityQueue<>((a,b)->(a[1]==b[1])?b[0]-a[0]:a[1]-b[1]);\n        \n        //Find count\n        for(int n:nums){\n            map.put(n,map.getOrDefault(n,0)+1);\n        }\n        //Sort\n        //Insert to pq\n        for(int key:map.keySet()){\n            pq.add(new int[]{key,map.get(key)});\n        }\n        \n        int[] res=new int[nums.length];\n        int idx=0;\n        \n        while(!pq.isEmpty()){\n            int[] tmp=pq.poll();\n            while(tmp[1]-->0){\n                res[idx]=tmp[0];\n                idx++;\n            }\n        }\n        \n        return res;\n    }\n}\n```\nPlease **upvote**, if you like the solution:)
[]