Sorting a Select List Inline

I've been trying to get select list to order itself randomly with each page load. I finally got the following solution.

var len = $("list").options.length
for(var i=1;i<len;i++){
var rand = Math.floor(Math.random()*(i+1));
rand = rand||1/*force to 1 if zero, we don't want to swap the first element*/

var temp1text = st.options[i].text;
var temp1val = st.options[i].value;

var temp2text = st.options[rand].text;
var temp2val = st.options[rand].value;

st.options[i].text = temp2text;
st.options[i].value= temp2val;

st.options[rand].text = temp1text;
st.options[rand].value = temp1val;
}

It still needs some work. To clean it a bit. Initially I tried sorting the actual Option objects in st.options, but that is not a proper array, since it auto-collapses when you remove an item, and I found no way to insert a node at an arbitrary index. So I just moved the values around.

The algorithm came from this page, which was incredibly helpful. It's a nice clean algorithm that hopefully won't require so much tweaking when I use it on normal arrays.

What took a little work was getting it to leave the first element alone. Since the first element is "chose an item..." I didn't want it moving around. This is why my numbers aren't exactly like the ones he uses.