[java/Python 3] Sort frequency followed by value.
\njava\n    public int[] frequencySort(int[] nums) {\n        var freq = new HashMap<Integer, Integer>();\n        for (int n : nums) {\n            freq.put(n,
\n```java\n    public int[] frequencySort(int[] nums) {\n        var freq = new HashMap<Integer, Integer>();\n        for (int n : nums) {\n            freq.put(n, 1 + freq.getOrDefault(n, 0));\n        }\n        var pq = new PriorityQueue<Integer>(Comparator.<Integer, Integer>comparing(i -> freq.get(i)).thenComparing(i -> -i));\n        for (int n : nums) {\n            pq.offer(n);\n        }\n        int[] ans = new int[nums.length];\n        for (int i = 0; !pq.isEmpty(); ++i) {\n            ans[i]= pq.poll();\n        }\n        return ans;\n    }\n```\n```python\n    def frequencySort(self, nums: List[int]) -> List[int]:\n        freq = Counter(nums)\n        return sorted(nums, key=lambda x : (freq[x], -x))\n```
[]