We are probably all used to the English alphabetical order:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
When we compare words in English for the sake of alphabetization we first compare the first letter, whichever word has the later first letter comes later. If they are the same we check the second letter and so on until we reach two letters that are different or one of the words runs out of letters to check in which case the word that ran out of letters comes first.
However in the Kiowa language, things work a little differently. The letters are ordered based on phonetic principles so the order is completely different:
A AU E I O U B F P V D J T TH G C K Q CH X S Z L Y W H M N
You will notice also that certain digraphs such as TH
are considered single letters.
We can use the same process for alphabetization with the Kiowa alphabetical order to get very different results.
We start by comparing the first letter, noticing that the digraphs AU
, TH
and CH
each count as a single letter. So if we are comparing AN
and AUN
, AN
comes first because A
comes before AU
, even though N
comes after U
.
If the first letters are the same we move onto the second letter repeating the process and so on until we reach two letters that are different or one of the words runs out of letters to check in which case the word that ran out of letters comes first.
Task
You will take two non-empty strings as input and output the string which comes first in terms of the alphabetization described above.
You may alternatively choose to always output the string which comes last or both strings in either ascending or descending order as long as you do so consistently.
The input strings will only consist of a sequence of letters from the Kiowa alphabet as described above in upper case.
This is code-golf so the goal is to minimize the size of your source code as measured in bytes.
Test cases
Here we output the string which comes earlier.
A N -> A
N A -> A
EEED EEEE -> EEEE
EVEV EVEV -> EVEV
AN AUN -> AN
CH CN -> CN
CH CA -> CA
CH KH -> KH
CH XA -> CH
Some simplifications are made here to serve the purpose of this challenge. Natural languages are wonderfully complex things and you should not take anything here as fact. However if you are interested I encourage you to learn more as the details can be quite interesting.