I am looking for an algorithm that will sort option values alphabetically.
$(this).html($("option", $(this)).sort(function(a, b) {
return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
}));
With this above code it appears that its working, however as soon as I introduce multiple works, sorting becomes unpredictable.
Let say or example I am trying to sort this:
<select class='whatever'>
<option value='Lorem dva'>Lorem dva</option>
<option value='a1'>a1</option>
<option value='pl1'>pl1</option>
</select>
I am using jQuery.
Thank you!
/
in jQuery?](http://stackoverflow.com/questions/304396/what-is-the-easiest-way-to-order-a-ul-ol-in-jquery)
– dtech Dec 13 '13 at 19:37