I have the following code to sort the items in a dropdown list:
function sortDropDownListByText(selectId) {
$(selectId).html($(selectId + \" option\").so
function sortDropDownListByText(selectId) {
var foption = $('#'+ selectId + ' option:first');
var soptions = $('#'+ selectId + ' option:not(:first)').sort(function(a, b) {
return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
});
$('#' + selectId).html(soptions).prepend(foption);
};
is your function.