공부

[JS] Sort array ASC, DESC

승가비 2020. 2. 9. 02:48
728x90
function sortNumber(a, b) {
  return a - b;
}

var numArray = [140000, 104, 99];
numArray.sort(sortNumber);

console.log(numArray);

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

728x90
저작자표시 비영리 (새창열림)