def map_table(list)
  table = {}
  list.each_with_index do |item, i|
    item.split(',').each do |subitem|
      table[Unicode.normalize_KC(subitem)] = (?a + i).chr
    end
  end
  table
end

ES_SORT = map_table(%w(
  a,A,á,Á b,B c,C d,D e,E,é,É f,F g,G h,H i,I,í,Í j,J k,K l,L m,M
  n,N ñ,Ñ o,O,ó,Ó p,P q,Q r,R s,S t,T u,U,ú,Ú v,V w,W x,X y,Y z,Z
))

def transform_es(str)
  array = Unicode.normalize_KC(str).scan(/./u)
  array.map {|c| ES_SORT[c] || c}.join
end

array = %w[éste estoy año apogeo amor]

array.map {|a| transform_es(a) } # ["etue", "etupz", "aop", "aqpgep", "amps"]

collate(array) {|a| transform_es(a) } # ["amor", "año", "apogeo", "éste", "estoy"]

