I have a form and I would like to sort my dropdown and checkboxes field in alphabetic order. I tried to use a javascript but it is not working.
$(function() {
var select = $('select');
select.html(select.find('option').sort(function(x, y) {
return $(x).text() > $(y).text() ? 1 : -1;
}));
// $('select').get(0).selectedIndex = 0;
});
Thank you for your help