Is there any way to sort my list generated by select2 by name? I have some code :
var dataUser = [{
"id": "5",
"text": "BTest"
}, {
"id": "2",
"text": "ATest"
}, {
"id": "8",
"text": "CTest"
}, {
"id": "13",
"text": "DTest"
}];
$("#mylist").select2({
data: dataUser,
templateResult: function(data) {
return data.text;
},
sorter: function(data) {
return data.sort();
}
});
http://jsfiddle.net/oe9retsL/4/
This list sorts by id, but I want sort by text.