Organizing a Hash Map

Hello, I have a hash map that gets pumped full of info. The key is a username... I'm using a @myhashmap.each do |key, item| to display the hash map in my rhtml, but I need it to be alphabetized... Is there a built-in way to do this?

Thanks, - Jeff Miller

hashes in ruby don't have a guaranteed order (at least not in 1.8. Ruby 1.9 is different). Your best bet is probably to sort the keys and iterate on that.

Fred

Hello, I have a hash map that gets pumped full of info. The key is a username... I'm using a @myhashmap.each do |key, item| to display the hash map in my rhtml, but I need it to be alphabetized... Is there a built-in way to do this?

@myhashmap.sort.each do |key, item| ...

Thanks, - Jeff Miller

--Greg

sort worked great, thanks!

gem install orderedhash