Improving performance while sorting a JavaScript Object 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 &gt; 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?
Disclaimer: I don't know anything about javascript  

If you have a construct like  

if (condition){
   return someValue;
} else { 
   return someOtherValue;
}


the else can be omited, because if the first condition is true the else is never reached.  

So your code could be refactored to  

filtered.sort(function (a, b) {
  if (!b.sortdist) { return -1; }
  if (!a.sortdist || a.sortdist &gt; b.sortdist) { return 1; }
  return -1;
});  


which doesn't improve the performance, but I don't see anything to make your code faster.