#C10961. Smallest Lexicographical Array

    ID: 40224 Type: Default 1000ms 256MiB

Smallest Lexicographical Array

Smallest Lexicographical Array

Given an array of N integers, your task is to transform the array into its smallest lexicographical order by simply sorting it in non-decreasing order. For each test case, you are provided with an integer N followed by N space-separated integers.

The lexicographical order is achieved by sorting the array. For an empty array, simply output an empty line.

Note: This problem requires you to handle multiple test cases. Use efficient sorting algorithms as the size of the array can be large.

Mathematical representation:

Let \(A = [a_1, a_2, \dots, a_N]\). The goal is to output \(A' = \text{sort}(A)\), where \(a'_1 \leq a'_2 \leq \dots \leq a'_N\).

inputFormat

The input begins with a single integer T denoting the number of test cases. Each test case consists of two lines:

  • The first line contains an integer N, the number of elements in the array.
  • The second line contains N space-separated integers.

outputFormat

For each test case, output a single line representing the sorted array (i.e. the smallest lexicographical order), with the numbers separated by a single space. If the array is empty, output an empty line.

## sample
3
4
4 3 2 1
5
1 3 5 4 2
3
2 3 1
1 2 3 4

1 2 3 4 5 1 2 3

</p>