I have a two dimensional array where the first is the distance and second is the object:
[distance][object]
I need to order by distance - I'm trying something like this but it doesn`t work, someone could help me?
lista.sort((a, b) => {return a-b});
and
let t = lista.sort(sortFunction);
sortFunction(a, b) {
if (a[0] === b[0]) {
return 0;
}
else {
return (a[0] < b[0]) ? -1 : 1;
}
}