I am sorting an array (filtered
) containing JS-Objects by their attribute sortdist
:
filtered.sort(function (a, b) {
if (!a.sortdist) { return 1;}
else if (!b.sortdist) { return -1;}
else if (a.sortdist > b.sortdist) { return 1;}
else { return -1; }
});
However, I am sorting 9000 datasets, which takes a really long time. Is there any way to improve the performance of my sorting algorithm?
sortdist
? Can they be equal? What if they are both undefined? – RoToRa Mar 7 at 11:15