I have tried variations of two similar questions here:
Sort mixed alpha/numeric array
and here:
Sort mixed alpha/numeric Array in javascript
But can't get the sort algorithm correct.
For example this solution:
const sortAlphaNum = (a, b) => a.localeCompare(b, 'en', { numeric: true })`
Gives it in the format of ["A1", "A2", "A3"...]
whereas I want it in the format of ["A1", "B1", "C1"...]
.
The array ranges from A1
to M30
if that helps so only one letter but two numbers.