When user selects many items (tags), they are automatically sorted alphabetically. How to prevent automatic sort and keep user\'s order using Select2 4.0?
Update:
This has been discussed before for Select2 3.5.2, you can use select2('data') to get the order.
$("select").select2();
$('#sayResult').click(function () {
// 'data' brings the unordered list, while val does not
var data = $('select').select2('data');
// Push each item into an array
var finalResult = data.map(function () {
return this.id;
});
// Display the result with a comma
alert( finalResult.join(',') );
});