Changing order of hash

I’ve got a constant of difficulty levels in my ‘Tutorial’ model which is
a hash of

DIFFICULTIES = {“Beginner” => 1, “Intermediate” => 2, “Advanced” => 3}

However when I pass it to my options_for_select helper they appear in a
completely different order. Is there any way to keep them in the correct
order?

Also is this the best way to keep a small list like this that isn’t
related to a database table?

On 7 Jan 2009, at 11:08, David Nicholson wrote:

correct
order?

Hashes are unordered (at least in ruby 1.8). As far as
options_for_select is concerned you can use something like
[[‘Beginner’, 1], …]

Also is this the best way to keep a small list like this that isn’t
related to a database table?

constant in the tutorial model sounds fine to me.

Fred

Can’t you use .sort Method or switch to Ruby 1.9?
Here a tip from Ezra Z.
http://www.ruby-forum.com/topic/50146#16582

Chris

Thanks a lot

The array method did the trick.