티스토리 뷰

공부

[JS] Sort array ASC, DESC

seunggabi 승가비 2020. 2. 9. 02:48
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

'공부' 카테고리의 다른 글

[Python] Selenium in private mode  (0) 2020.02.09
[JS] Sort object property  (0) 2020.02.09
[JS] Sort array ASC, DESC  (0) 2020.02.09
[JS] unique array  (0) 2020.02.09
[Python] Subtract array  (0) 2020.02.09
[Python] Sort array Sting by int  (0) 2020.02.09
댓글
댓글쓰기 폼