Part 15 of 15 in Sorting  

Lexicographical Sorting by animeshn

Problem statement

Given a list of strings, sort the strings in lexicographical order (dictionary order).

Input

First line of input will contain a number T = no, of test cases. Each test case will contain 2 lines. First line will contain N = number of strings in a list. Next line will contain N strings comprising of only lower case letters ('a' to 'z') separated by space.

Output

For each test case, print on a single line, the strings as space separated list in lexicographical order (dictionary order). There should be no space after last element in the list.

Sample Input
3
6
program sort loop sentence fragment bracket
5
wheel car mile meter yard
10
cat rat bat hat vat mat pet set met fat 
Sample Output
bracket fragment loop program sentence sort
car meter mile wheel yard
bat cat fat hat mat met pet rat set vat
Explanation

Lexicographical order is the order in which strings will occur in dictionary.



To try out your code



Sign in

Sign up