Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Sort first half in ascending and second half in descending
Basic Accuracy: 41.61% Submissions: 2680 Points: 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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Sort first half in ascending and second half in descending

Output Window