Minsik Language Word Sorting
InterviewTime limit2sMemory limit128 MB
Sort Minsik language words using a custom 20-letter alphabet where the digraph 'ng' counts as a single letter between 'n' and 'o'.
- Level
Medium4 of 10
- Topics
- String, Sorting, Implementation
- Solved
- No attempts yet
Problem
The Minsik language has the following 20 letters, and dictionary order follows this order.
a b k d e g h i l m n ng o p r s t u w y
The sequence ng is not two separate letters; it is treated as one letter placed between n and o. Whenever ng appears in a word, compare it as that single letter.
Given several words in the Minsik language, sort them in dictionary order according to this alphabet.
Input
The first line contains the number of Minsik language words, N. N is a positive integer not greater than 50.
Each of the next N lines contains one Minsik language word. Each word has length at most 50. No input word contains a letter outside the Minsik alphabet, and all words are distinct.
Output
Print the sorted words, one per line.