Given an array Arr[] of N **distinct** integers, print the array in such a way that the first element is first maximum and second element is first minimum and so on.

**Input:**

First line of input contains a single integer T which denotes the number of test cases. Then T test case follows. First line of each test case contains a single integer N which denotes the number of elements in the array. Second line of each test case contains N space separated integers.

**Output:**

For each test case print the given array in such a way that the first element is first maximum and second element is first minimum and so on.

**Constraints:**

1<=T<=100

1<=N<=10^{4}

1<=Arr[i]<=10^{5}

**Example:
Input:**

2

7

7 1 2 3 4 5 6

8

1 6 9 4 3 7 8 2

7 1 6 2 5 4 3

9 1 8 2 7 3 6 4

Author: harsh.agarwal0

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.

saiujwal13083 | 489 |

sudeep235poojary | 302 |

VithalNakod | 272 |

AshutoshPal1 | 254 |

go__karuna | 253 |

Soseph_Jtalin | 792 |

AshutoshPal1 | 722 |

architjindal__ | 648 |

go__karuna | 577 |

ArbazGrewal | 527 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4931 |

Quandray | 4598 |

Login to report an issue on this page.