From: MonkeeSage Date: 2007-12-08T22:15:00+09:00 Subject: Re: sorting Array of accentuated Strings On Dec 8, 1:09 am, unbewusst.s...@weltanschauung.com.invalid (Une Bévue) wrote: > cruiserdan wrote: > > > You might be interested in using some of the emerging Unicode support > > in Ruby. Ruby 2 will have it built-in and there are several libraries > > out there, although I don't have any experience using them. > > right, thanks, i've only wrote a workaround before getting Ruby 2... > -- > Une Bévue Hmmm. Maybe I'm mistaken, but this seems to have nothing to do with unicode. An ascii char is always going to be less than a utf-8 char, since utf-8 is a superset of ascii. Fenêtre <=> Être -> F (\x46) <=> Ê (\xc3\x8a) -> -1 To get the right behavior I think you have to translate the utf-8 characters to ascii. You can try something like: require 'iconv' class String def translit Iconv.iconv('ascii//translit', 'utf-8', self)[0] end end a.sort { | i, j | i.translit <=> j.translit } But some people have had strange effects from #iconv (e.g., a recent thread [1]). Regards, Jordan [1] http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/9fbb85fa49dd700f/26311c1a3844267d#26311c1a3844267d