


The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘2*T’ lines represent the ‘T’ test cases.
The first line of each test case contains an integer ‘N' denoting the size of the array.
The second line of each test case contains ‘N’ space-separated integers consisting of 0s and 1s as the array elements.
For each test case, print ‘N’ space-separated integers representing the elements of the sorted binary array in a separate line.
Print the output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1. Can you solve this problem in a linear time and constant space?
2. Can you solve this problem in a single traversal only?
1 <= T <= 50
1 <= N <= 10^4
0 <= arr[i] <= 1
Where ‘T’ is the number of test cases and ‘N’ is the size of the array.
Time Limit: 1 sec
Note -: Instead of counting 0 we can also count 1 in the given array and similarly solve this problem.
This problem can be solved in a single traversal also. The concept used for this approach is related to the partition of quicksort. In a quick sort’ partition, after one scan, the left of the array is the smallest and the right of the array is the largest of the selected pivot element. Here we don't make any pivot but we make the smaller(0) come back in the array and Larger value(1) go ahead in the array.