#!ruby -n h=Hash.new 0 gsub(/[A-z]+/){h[$&]+=[1,$'.oct].max} puts h.sort_by{|k,|k.sum**5%26}.map{|a|(a*"").tr ?1,""}*" "