In this homework, you are asked to re-sort a sorted array with our own comparison function.
Suppose A is a sorted array in increasing order. We say that A[i] <* A[j] if one of these statements is true:
For example:
If A = [-8, -2, -1, 0, 1, 6, 10]
Then you should re-sort A as A* = [0, -1, 1, -2, 6, -8, 10]
If A = [-795, -594, -356, -123, -46, -21]
Then you should re-sort A as A* = [-21, -46, -123, -356, -594, -795]
You are allowed to use STL.
But don’t use any STL related to sort.
There are multiple test cases, and each test case begins with a line containing an integers n, which is the number of elements in the input.
The next line includes the n sorted integers (in increasing order) in the sequence.
Please note:
Output the re-sorted array in increasing order with our own comparison function.
In other words, if x <* y then x must appear before y.
Add a new line to each output.