Lexical Sorting Reloaded
Practice
4.5 (2 votes)
Ready
Sorting
Approved
Easy
Approved
Problem
52% Success 1202 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

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

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
4 votes
Tags:
Easy-Medium
Points:20
1 votes
Tags:
EasySimple-math
Points:30
4 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingMediumOpen