#K95917. Stable Sort Books by Number of Pages

    ID: 38970 Type: Default 1000ms 256MiB

Stable Sort Books by Number of Pages

Stable Sort Books by Number of Pages

In this problem, you are given several test cases. Each test case contains a list of books with their page counts. Your task is to sort the page counts in non-decreasing order while preserving the relative order of equal elements (i.e., the sort must be stable).

For example, if a test case has page counts of 100, 300, 200, 100, 400, the output should be 100, 100, 200, 300, 400.

inputFormat

The input is read from stdin and begins with an integer T indicating the number of test cases. Each test case starts with an integer N (the number of books) followed by a line containing N integers representing the page counts of the books.

outputFormat

For each test case, output a single line containing the sorted page counts separated by a single space. The output should be written to stdout.## sample

3
5
100 300 200 100 400
4
500 100 100 200
6
50 40 50 30 20 50
100 100 200 300 400

100 100 200 500 20 30 40 50 50 50

</p>