I have one array called myArr in my javascript like below.
["ob1","ob10","ob4","ob5","ob12"]
When I do sorting on this array, it doesn't sort in order of the number because it is a string number. Therefore I use below method to sort the array and now it works.
var collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
myArr .sort(collator.compare);
However this method is not suported in IE9. Is there any method that i can use to sort this kind of array in IE?
myArr.sort( function(a, b) { var an = parseInt(a.replace( /^\D+/g, '')); var bn = parseInt(b.replace( /^\D+/g, '')); return bn - an; })arr.sort((a,b) => a.localeCompare(b, undefined, {numeric: true}));