I am looking for a function that will take a list of options in a select list and sort them alphabetically but with a twist. All values with the text \'NA\' should be pushed to
var sb = $('select'); sb.append(sb.find('option').sort(function(a, b){ return ( a = $(a).text(), b = $(b).text(), a == 'NA' ? 1 : b == 'NA' ? -1 : 0|a > b ); }));