Sort first half in ascending and second half in descending
Submissions: 1945   Accuracy:

40.38%

  Difficulty: Basic   Marks: 1

Given an array of integers, sort the first half of the array in ascending order and second half in descending order.

Input:
The first line consists of an integer T i.e number of test cases. The first line of each test case consists of an integers N.The next line consists of N spaced integers. 

Output:
Print the required output.

Constraints: 
1<=T<=100
1<=N<=100
1<=a[i]<=1000

Example:
Input:

2
9
5 2 4 7 9 3 1 6 8
6
1 2 3 4 5 6

Output:
1 2 3 4 9 8 7 6 5
1 2 3 6 5 4

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Ashtputre
Author: saksham0751


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.