Hash sort

I am trying to sort a hash and it seams to be working, the issue is that
the sort goes from Z-A. Is there a way to make it sort A-Z? My code is
pretty straight foward, I have a hash - @users - and I just say
@hash.sort to sort it.

Thanks,

-S

Shandy N. wrote:

I am trying to sort a hash and it seams to be working, the issue is that
the sort goes from Z-A. Is there a way to make it sort A-Z? My code is
pretty straight foward, I have a hash - @users - and I just say
@hash.sort to sort it.

Thanks,

-S

Figured it out. Part of my issue was that the key - which are string -
that I was trying to sort were in upper and lowercase, once I converted
them to lower case everything was fine. Here is the code I used:

@users.sort.each { |f| puts “#{f[0]} : #{f[1]}” }

This will print out the key (in f[0]) and the value (in f[1]).