All Tracks Problem

Lexical Sorting Reloaded
Tag(s):

Easy, Sorting, approved

Problem
Editorial
Analytics

Little Ravi is designing an application but has got some problems. His application should keep the input strings in lexicographical order which isn't working properly.

Please help Little Ravi in completing his application. Ravi has N strings which will be given to you that are to be arranged in lexicographical order.

The strings have both capital and small letters. In general, their is no priority when strings do not spell the same. But if the strings spell same, small letter is considered having higher priority over capital letters.

A string may contain multiple words. Also a space is of higher priority over any alphabets.

Refer sample test cases for proper understanding.

Input :
First line has number of test cases.
First line of each test case has N(Number of strings Little Ravi has).
Next N lines has a string in each line.
It is guaranteed that string doesn't start or end with a space.

Output :
For each test case, print N lines with a string in each line in order as described.

Constraints :
1 ≤ T ≤ 1000
1 ≤ N ≤ 1000
1 ≤ |S| ≤ 1000, |S| means length of string.
Sum of length of strings over all test cases in an input file wouldn't exceed 107

SAMPLE INPUT
4
3
fuNny
funny
fun
5
All
hall
Fall
ball
Call
2
hello world
World Hello
5
HellO
hello
HEllo
hellO
Hello

SAMPLE OUTPUT
fun
funny
fuNny
All
ball
Call
Fall
hall
hello world
World Hello
hello
hellO
Hello
HellO
HEllo
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Zauba Technologies & Data Services Private Limited

Challenge Name

Zauba Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications