I wrote this up today and it is working fine, however, I noticed the capitalization is taking preference in the sorting... how can I go about sorting this case insensitive while preserving the original strings?
// original data
var data = 'keyword,another,test,546,Hello';
//if keywords then split them by comma into an array
var keyArray = new Array();
keyArray = data.split(",");
// sort the new array alpha
keyArray.sort();
// now output as nice display
var keyOut = '';
var keyLength = keyArray.length;
for (var i = 0; i < keyLength; i++) {
//create output
var keyOut = keyOut.concat('<span class="label label-default">'+keyArray[i]+'</span> ');
}
return keyOut;
EDIT :
Answered my own after finding a quick example and working as expected...
keyArray.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});