Hi,

I have a few select lists that are sorted alphabetically using the below code but it isn't sorting the numbers right. Its displaying like the example below:

Its doing:

150
200
50

When it should be:

50
150
200

Id like to sort just this one select list in numerical order. Can anyone help please as I am stuck and just learning Javascript

Code:
function sortDropDownListByText() {
    // Loop for each select element on the page.
    $("select").each(function() {
         
        // Keep track of the selected option.
        var selectedValue = $(this).val();
 
        // Sort all the options by text. I could easily sort these by val.
        $(this).html($("option", $(this)).sort(function(a, b) {
            return a.text == b.text ? 0 : a.text < b.text ? -1 : 1
        }));
 
        // Select one option.
        $(this).val(selectedValue);
    });
}
Many thanks
Joe