I have a sort function that sorts yard names (which arte strings) alphabetically.
const sortList = (list, col) => {
return list.sort((a, b) => {
if (!b[col] && !a[col])
return 0
if (!a[col])
return -1
if (!b[col])
return 1
if (a[col] < b[col])
return -1
if (a[col] > b[col])
return 1
else return 0
})
};
However sometimes, the yards have number in them and the sorting looks like this:
I have tried adding attr to a[col] and b[col] but it produced even weirder results. Is there an idea on how to avoid this type of behaviour?