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
demo: http://jsfiddle.net/4bvVz/
function NASort(a, b) { if (a.innerHTML == 'NA') { return 1; } else if (b.innerHTML == 'NA') { return -1; } return (a.innerHTML > b.innerHTML) ? 1 : -1; }; $('select option').sort(NASort).appendTo('select');