I use the Select2 plugin ( http://ivaynberg.imtqy.com/select2/ ), and, as you can see from the list of tags that I have in the screenshot, they are not listed in alphabetical order, and I would like to be able to do this.

EDIT: This is what I have now, but instead of asking, I want to sort the data (@appTags) using "text", not "id":
scope.find('input[name=noun]').select2({
data: @appTags,
sortResults: function(results, container, query) {
if (query.term) {
return results.sort();
}
return results;
}
});
Screenshots of my console are suspended in Debugger:

Here is an image of the @appTags object that I would like to sort by "text":

source
share