I have a web service that is supposed to return a list of translation keys in alphabetical order. But it actually does not do so when underscores are involved. It sends the keys in this order:
en.orders
en.order_mail
whereas I expect the order to be this:
en.order_mail
en.orders
which is the order given by sorting strings:
["en.orders", "en.order_mail"].sort
# => ["en.order_mail", "en.orders"]
I'm not sure how to handle this. I've tried removing underscores, replacing them with other characters etc. but it always has some unwanted side effects.
Is there a way to treat the underscore differently when sorting arrays?