I want to actualize this sorted result in javascript.
A1-1, A1-3, A1-3-1, A1-4, A2, A4-1, A6-3, A13-1, A13-2, A13-3, A13-11, A13-14, A51-2
But I have the below result with this code.
sortedAlphabetListData.sort(
function(a,b){
if( a[0] < b[0] ) return -1;
if( a[0] > b[0] ) return 1;
return 0;
}
);
A1-1, A1-3, A1-3-1, A1-4, A13-1, A13-11, A13-14, A13-2, A13-3, A2, A4-1, A51-2, A6-3
I tried this library. https://gist.github.com/think49/660141 But it didn't work. "A23" came first and "A3-1" came after.
I read this post and tried it. Javascript : natural sort of alphanumerical strings
var collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
var sortedAlphabetListData = alphabetListData.sort(collator.compare);
But it works only over IE11 and doesn't work on Safari. I need to support IE9 and safari.
I need your help. Thank you!