Sort by values from hash table - Ruby

Posted by Adnan on Stack Overflow See other posts from Stack Overflow or by Adnan
Published on 2010-03-16T14:13:14Z Indexed on 2010/03/16 14:16 UTC
Read the original article Hit count: 315

Filed under:
|
|

Hello,

I have the following hash of countries;

COUNTRIES = {
  'Albania' => 'AL', 
  'Austria' => 'AT',
  'Belgium' => 'BE',
  'Bulgaria' => 'BG',
   .....
  }

Now when I output the hash the values are not ordered alphabetically AL, AT, BE, BG ....but rather in a nonsense order (at least for me)

How can I output the hash having the values ordered alphabetically?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby