Rearrange the array
Submissions: 3128   Accuracy:

39.45%

  Difficulty: Basic   Marks: 1

Given an array of integers, task is to print the array in the order – smallest number, Largest number, 2nd smallest number, 2nd largest number, 3rd smallest number, 3rd largest number and so on..

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 integer N.The next line consists of N spaced integers. 

Output:
Print the required answer.

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

Example:
Input:

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

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

** 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.