javascript - How to sort an array of integers correctly - Stack Overflow

PHOTO EMBED

Mon Apr 11 2022 14:50:59 GMT+0000 (Coordinated Universal Time)

Saved by [deleted user] #javascript

var numArray = [140000, 104, 99];
numArray.sort(function(a, b) {
  return a - b;
});

console.log(numArray);
content_copyCOPY

https://stackoverflow.com/questions/1063007/how-to-sort-an-array-of-integers-correctly