Before 1994, Spanish dictionaries used alphabetical order with a peculiarity: digraphs
ch were considered as if they were single letters.
ch immediately followed
c , and
ll immediately followed
l. Adding the letter
ñ, which follows
n in Spanish, the order was then:
a, b, c, ch, d, e, f, g, h, i, j, k, l, ll, m, n, ñ, o, p, q, r, s, t, u, v, w, x, y, z
ch are considered as groups of two letters (
h respectively), and thus alphabetical order is the same as in English, with the exception of the letter
The old order was definitely more interesting.
Input a list of zero or more words and output the list sorted according to the old Spanish alphabetical order. Sorting is between words (not between letters within a word). That is, words are atomic, and the output will contain the same words in a possibly different order.
To simplify, we will not consider letter
ñ, or accented vowels
ú, or uppercase letters. Each word will be a sequence of one or more characters taken from the inclusive range from ASCII 97 (
a) through ASCII 122 (
If there are more than two
l letters in a row, they should be grouped left to right. That is,
ll and then
l and then
Input format can be: words separated by spaces, by newlines, or any convenient character. Words may be surrounded by quotation marks or not, at your choice. A list or array of words is also acceptable. Any reasonable format is valid; just state it in your answer.
In a similar way, output will be any reasonable format (not necessarily the same as the input).
Code golf, shortest wins.
In the following examples words are separated by spaces. First line is input, second is output:
llama coche luego cocina caldo callar calma caldo calma callar cocina coche luego llama cuchara cuchillo cubiertos cuco cueva cubiertos cuco cuchara cuchillo cueva
"Words" can be single letters too:
b c a ch ll m l n a b c ch l ll m n
or unlikely combinations (remember the rule that
l's are grouped left to right):
lll llc llz llll lllz llc lll lllz llll llz
An empty input should give an empty output:
Of course, this order can be applied to other languages as well:
chiaro diventare cucchiaio cucchiaio chiaro diventare all alternative almond at ally a amber a almond alternative all ally amber at