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?
ParseInt(a[col].substr(5));To just get the number, but I'm guessing that's not going to fix your problem.ifandif-elseblocks and replace it with:return a[col].localeCompare(b[col], undefined, { numeric: true })listwithcolproperties.String(a[col])andString(b[col]). Ora[col].toString()