sortsre
You are given n strings with different (and odd) lengths. The goal is to sort the strings using the following comparison function: for two strings A and B you look at their middle character, then the one to the right of the middle one, then to one to the left of the middle one, then the 2nd to the right of the middle one, then the second to the left of the middle one, and so on... for the first pair of characters that don't match you compare their values.
InputThe first line contains an integer n (1 <= n <= 1.000). Following n lines contain n odd length strings with no more than 1999 characters.
OutputIn n lines write the strings in sorted order.
Input:
Output:
5
zbc
abcde
informatika
aabcdea
aaaaaaaaaaaaaOutput:
aaaaaaaaaaaaa
zbc
abcde
aabcdea
informatikaSubmit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.