How can I sort an array of accented words by the every letter in reference to variable alpha. The code below only reference alpha for the first letter so I am unable to get "ĝusti
", "ĝusti vin
","ĝuspa
" to sort correctly.
I need the code to sort the words like this:
["bonan matenon", "ĉu vi parolas esperanton","ĝuspa", "ĝusti", "ĝusti vin", "mi amas vin", "pacon"]
def alphabetize(phrases)
alpha = "abcĉdefgĝhĥijĵklmnoprsŝtuŭvz".split(//)
phrases.sort_by { |phrase|
alpha.index(phrase[0])
}
end
alphabetize(["mi amas vin", "bonan matenon", "pacon", "ĉu vi parolas esperanton", "ĝusti", "ĝusti vin","ĝuspa"])