I have a string array as below.
let arr = ["1", "1+", "1-","2", "2+", "3","3+", "2-", "3-", "4", "10"];
I want the expected output as below.
["1+", "1", "1-", "2+", "2", "2-", "3+", "3", "3-", "4", "10"];
I tried the below code but it is not giving me the correct result.
let arr = ["1", "1+", "1-","2", "2+", "3","3+", "2-", "3-", "4", "10"];
let result = arr.sort((a,b) => {
return a.localeCompare(b, undefined, {
numeric: true,
sensitivity: 'base',
});
});
console.log(result);