For this Question: Given an array A[] of integers, sort the array according to frequency of elements. That is elements that have higher frequency come first. If frequencies of two elements are same, then smaller number comes first.The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains a single integer N denoting the size of an array. The second line contains N space-separated integers A<sub>1</sub>, A<sub>2</sub>, ..., A<sub>N</sub> denoting the elements of the array.

Constraints:
1 &le; T &le; 100
1 &le; N &le;10<sup>5</sup>
1 &le;A[i] &le; 10<sup>4</sup>

The Sum of N over all test cases does not exceed 2*10<sup>5</sup>
For each testcase, in a new line, print each sorted array in a separate line. For each array its numbers should be separated by space.Sample Input:
2
5
5 5 4 6 4
5
9 9 9 2 5

Sample Output:
4 4 5 5 6
9 9 9 2 5

<b>Explanation:</b>
Test Case 1: The highest frequency here is 2. Both 5 and 4 have that frequency. Now since the frequencies are the same then smaller element comes first. So 4 4 comes first then comes 5 5. Finally comes 6.
The output is 4 4 5 5 6.

Test Case2: The highest frequency here is 3. The element 9 has the highest frequency. So 9 9 9 comes first. Now both 2 and 5 have same frequency. So we print smaller element first.
The output is 9 9 9 2 5., I have written this Solution Code: from collections import defaultdict
test = int(input())
while(test != 0):
    test -= 1
    n = int(input())
    arr = list(map(int, input().split()))
    freq = defaultdict(list)
    temp = [0]*(max(arr) + 1)
    for i in arr:
        temp[i] += 1
    for i in range(1,len(temp)):
        if(temp[i] == 0):
            continue
        freq[temp[i]].append(i)
    for i in sorted(freq.keys(), reverse=True):
        x = freq[i]
        x = sorted(x*i)
        print(*x, end=" ")
    print(), In this Programming Language: Python, Now tell me if this Code is compilable or not?