Firstly I could not find a question addressing the whole issue.
I used to compare arrays like this:
array.sort((a, b) => {
return a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})
})
But I realized it does not work on an array like ['a', 'A', 'B', -1.50', '0', '1.50', '-2', '2']
.
The expected output would be: ['-2', '-1.50', '0', '1.50', '2', 'A', 'a', 'B']
.
I have some dirty ideas to achieve it. But maybe there is a clean and easy way.