Given an array:
var myList = [ \'Normal\', \'Urgent\', \'Alert\', \'Casual\', \'Follow up\' ];
I want to output this list in say, a dropdown. I
It's best if you keep your prioritized elements separate from the main list, if you can't guarantee they will be present. I would filter those elements out, sort the rest, and concatenate the results with your special list.
var special = ["Urgent","Alert"];
var myList = [ 'Normal', 'Urgent', 'Alert', 'Casual', 'Follow up' ];
myList = special.concat(myList.filter(function(el){ return special.indexOf(el) == -1; }).sort());
alert(myList);