I have a select box that dynamically shows a list of shipping options and prices. I want them to be in order from lowest to highest price.
Here's example html.
<select name="ShippingMethod">
<option value="ups:1">UPS Next Day Air ($30.08)</option>
<option value="ups:4">UPS 2nd Day Air ($14.77)</option>
<option value="ups:6">UPS 3 Day Select ($10.93)</option>
<option value="ups:7">UPS Ground ($8.00)</option>
<option value="flatzonc:Pick up in store">Pick up in store ($0.00)</option>
<option value="mvusps:PRIORITY">U.S.P.S. Priority Mail® ($7.45)</option>
</select>
I know how to put the values into an array with this:
shippingOptions = [];
$('select[name=ShippingMethod] option').each(function() {
myList.push($(this).html())
});
but thats as far as I got. I don't know how to use that to sort them and reinsert them in order. I'm new to javascript so I appriciate the help.
Thanks