Using a locale-dependent sorting function in Ruby/Rails

Posted by knuton on Stack Overflow See other posts from Stack Overflow or by knuton
Published on 2010-04-19T07:56:40Z Indexed on 2010/04/19 8:03 UTC
Read the original article Hit count: 220

Filed under:
|
|
|
|

What is a good approach to sorting an array of strings in accordance with the current locale?

For example the standard Array#sort puts "Ä" after "Z", which is not correct in German.

I would have expected the gem I18n to offer a hook for defining my own sorting algorithms or providing collation strings or objects. In my imagination, passing this proc or string to the sort function, would make it behave as necessary. I know that this is possible in Python, for example.

Google has not helped me this time. Can you?

Any advice appreciated!

© Stack Overflow or respective owner

Related posts about rails

Related posts about ruby