#K45097. Sheldon's Selection Sort

    ID: 27677 Type: Default 1000ms 256MiB

Sheldon's Selection Sort

Sheldon's Selection Sort

You are given several test cases. Each test case consists of a list of integers that must be sorted in ascending order using Sheldon's Selection Sort algorithm.

The algorithm works as follows: it iteratively identifies the maximum element within the unsorted part of the list and then swaps it with the last element of that segment. The sorting procedure has a worst-case time complexity of $\mathcal{O}(n^2)$.

Your task is to implement the sorting algorithm and print the sorted list for each test case.

inputFormat

The first line of input contains an integer $T$, representing the number of test cases. Each of the following $T$ lines contains a series of space-separated integers representing a test case.

outputFormat

For each test case, output a single line containing the sorted integers in ascending order, separated by a single space.

## sample
2
3 1 2
4 7 1 3 2
1 2 3

1 2 3 4 7

</p>