I have multiple radio buttons with different values. I would like to sort these buttons according to the value
or id
in this order:
- FedEx Ground
- UPS Ground
- Custom 1
- Custom 2
Since the classes and names are the same for all options, the values, and ID's differ. I've tried using JavaScript but besides using ascending, descending, and random sort, I cannot figure out how to sort the options in a custom order by value.
<ul id="shipping_method">
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_1" value="booster_custom_shipping_1" class="shipping_method" checked="checked">
<label for="shipping_method_custom_shipping_1">Custom 1:</label>
</li>
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_2" value="booster_custom_shipping_2" class="shipping_method">
<label for="shipping_method_custom_shipping_2">Custom 2:</label>
</li>
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_3" value="FedEx - FedEx Ground" class="shipping_method">
<label for="shipping_method_fedex_ground">FedEx Ground:</label>
</li>
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_4" value="UPS - UPS Ground" class="shipping_method">
<label for="shipping_method_ups-ground">UPS Ground:</label>
</li>
</ul>