Answers for "array.sort number"

3

sorting of arraray's number element in javascript

let numbers = [0, 1, 2, 3, 10, 20, 30];
numbers.sort((a, b) => a - b);

console.log(numbers);
Posted by: Guest on April-17-2020
0

sort array by a value js

arr.sort((a, b) => (a.nameofKeyFromArray < b.nameofKeyFromArray ? -1 : Number(a.nameofKeyFromArray > b.nameofKeyFromArray)));
Posted by: Guest on October-01-2021

Browse Popular Code Answers by Language