Sort multiselects alphabetically

This commit is contained in:
claudiulodro 2017-08-16 10:10:09 -07:00
parent 5ff7704db4
commit f0afd14ed3
4 changed files with 30 additions and 2 deletions

View File

@ -1689,6 +1689,20 @@ S2.define('select2/selection/multiple',[
return;
}
// Sort selected elements alphabetically by text.
data.sort(function(a, b){
atext = a.text.toLowerCase();
btext = b.text.toLowerCase();
if (atext > btext) {
return 1;
}
if (atext < btext) {
return -1;
}
return 0;
});
var $selections = [];
for (var d = 0; d < data.length; d++) {

File diff suppressed because one or more lines are too long

View File

@ -1689,6 +1689,20 @@ S2.define('select2/selection/multiple',[
return;
}
// Sort selected elements alphabetically by text.
data.sort(function(a, b){
atext = a.text.toLowerCase();
btext = b.text.toLowerCase();
if (atext > btext) {
return 1;
}
if (atext < btext) {
return -1;
}
return 0;
});
var $selections = [];
for (var d = 0; d < data.length; d++) {

File diff suppressed because one or more lines are too long