Sorting a select with fractions in jquery / javascript
<p>I would like to sort the below select options by their computed fractional value, excluding the --please select-- option.</p>

<pre><code>&lt;select class="wpsc_select_variation"&gt;
&lt;option value="0"&gt;-- Please Select --&lt;/option&gt;
&lt;option value="13"&gt;1"&lt;/option&gt;
&lt;option value="21"&gt;2''&lt;/option&gt;
&lt;option value="11"&gt;3/4"&lt;/option&gt;
&lt;option value="6"&gt;3/8"&lt;/option&gt;
&lt;option value="10"&gt;5/8"&lt;/option&gt;
&lt;option value="17"&gt;1-1/2''&lt;/option&gt;
&lt;option value="15"&gt;1-1/4''&lt;/option&gt;
&lt;option value="19"&gt;1-3/4''&lt;/option&gt;
&lt;option value="7"&gt;1/2"&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>Code I've put together so far:
Added to pastebin for brevity and history's sake.
<br /><h2><a href="http://pastebin.com/8reTt8sR" rel="nofollow">Link</a></h2></p>

<p>This would explain the length of the note 1 array being 3.
But why is it 3? Why isn't it 9?
Why does Chrome show the full array, but still have a length of 3, and Firefox show the full array after clicking the parent +, but the parent says undefined, option, option?</p>

<p>Confused...</p>

<p>EDITS:
Edit to allow for multiple select boxes:
Correct me if I'm wrong.</p>

<pre><code>$(".wpsc_select_variation").each(function(index, element){
        $($(element).children().get().sort(function (a, b) {
        return parseInt(a.value) - parseInt(b.value);
        })).appendTo($(element));
    });
</code></pre>

<p>Latest edit using objects.
Here goes:</p>

<pre><code>var els = new Array();
var counter = 0;
$j("select.wpsc_select_variation option").each(function(index, ele){
var obj = new Object;
var i = $j(ele).text();
i = i.replace("\"", "");
i = i.replace("''", "");
if (i.indexOf("-") &gt;= 0){
    i = i.split('-');
    split = i[1].split('/');
    i = eval(i[0]) + split[0] / split[1];
}
else if(i.indexOf("/") &gt;= 0){
    split = i.split('/');
    i = split[0] / split[1];
}
i = eval(i);
obj.ind = i;
obj.ele = ele;
els[counter] = obj;
counter++;
});
els.sort(function (a, b) { return parseInt(a.ind) - parseInt(b.ind) });
console.log(els);
</code></pre>

<p>The above results in:</p>

<pre><code>[Object { ind=NaN,  ele=option}, Object { ind=0.75,  ele=option}, Object { ind=0.375,  ele=option}, Object { ind=0.625,  ele=option}, Object { ind=0.5,  ele=option}, Object { ind=1,  ele=option}, Object { ind=1.5,  ele=option}, Object { ind=1.25,  ele=option}, Object { ind=1.75,  ele=option}, Object { ind=2,  ele=option}]
</code></pre>

<p>It appears to be sorting them somewhat, but as you can see, they are still out of order.</p>
