# Options\_for\_select and sorting

**URL:** <https://www.ruby-forum.com/t/options-for-select-and-sorting/111957>\
**Category:** Rails\
**Created:** [August 13, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/options-for-select-and-sorting/111957 "2007-08-13T20:57:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Parks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@Scott\_Parks](https://www.ruby-forum.com/u/Scott_Parks)\
**Post date:** [August 13, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/options-for-select-and-sorting/111957/1 "2007-08-13T20:57:50Z")

</div>

I have several select options on a form and was planning on using  
options\_for\_select.

If I use the code below the options do not appear in order on the  
form, I am not really  
sure of the order they are appearing since it is not alphabetical  
either.

\<%= options\_for\_select({“Co-ed” =\> “Co-ed”, “Men” =\> “Men”, “Women”  
=\> “Women”, “Please select student body” =\> “None”}, “None”) %\>

Would I be better off to use a traditional HTML tag and put  
my options in the  
order I want them to display?

For the record this is the order they display now on the form with  
the code above:

Men  
Please select student body  
Co-ed  
Women

Thanks!

-Scott

---

<div class="post-metadata">

**Author:** ![Scott\_Parks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@Scott\_Parks](https://www.ruby-forum.com/u/Scott_Parks)\
**Post date:** [August 13, 2007, 10:03pm UTC](https://www.ruby-forum.com/t/options-for-select-and-sorting/111957/2 "2007-08-13T22:03:02Z")

</div>

Instead of a hash, try passing in an ActiveSupport::OrderedHash

options = ActiveSupport::OrderedHash.new  
options[“Co-ed”] = “Co-ed”  
options["“Men”] = “Men”  
etc.

It is ugly tho ☹

Vish

---

<div class="post-metadata">

**Author:** ![Scott\_Parks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac8455/32.png) [@Scott\_Parks](https://www.ruby-forum.com/u/Scott_Parks)\
**Post date:** [August 14, 2007, 3:42am UTC](https://www.ruby-forum.com/t/options-for-select-and-sorting/111957/3 "2007-08-14T03:42:41Z")

</div>

That works, but as you said it is kind of ugly, this is a new user form  
so I am not worried about making the select’s sticky.

Do you see a need to do it this way if the values are static? Or is a  
regular tag ok?
