#K60002. Lexicographically Smallest Array
Lexicographically Smallest Array
Lexicographically Smallest Array
You are given an array of n integers. You are allowed to swap any two elements any number of times. Your task is to determine the lexicographically smallest array possible. In other words, output the array in non-decreasing order.
Note: Since any permutation is possible through swapping, the lexicographically smallest array is simply the sorted array.
The input consists of multiple test cases. For each test case, you are provided with the length of the array and then the array itself. Output the sorted array for each test case.
inputFormat
The first line contains an integer T
, the number of test cases. Each test case is described in the following two lines:
- An integer
n
representing the number of elements in the array. n
space-separated integers representing the array.
All input is given via standard input (stdin).
outputFormat
For each test case, output one line containing the lexicographically smallest array (i.e. the sorted array) with each element separated by a single space. Output the results to standard output (stdout).
## sample2
3
3 2 1
5
5 3 2 4 1
1 2 3
1 2 3 4 5
</p>