Just a comment on your code:
> sort.attr('selected')
seems to be using the jQuery attr method, which used to try and second guess what you wanted and return either the attribute or the property. I think in recent versions it returns the attribute always.
Anyway, the presence of the selected attribute only means that the item (an option element?) is the default selected option, it doesn't mean that it is the currently selected option. For that you need the selected property (jQuery prop method). And since the selected property is a boolean:
> sort.attr('selected') ? true : return false;
can simply be:
sort.prop('selected');
or without jQuery:
optionElement.selected;