Answers for "node js sort array"

25

JS array sort

numArray.sort((a, b) => a - b); // For ascending sort
numArray.sort((a, b) => b - a); // For descending sort
Posted by: Guest on May-08-2021
2

javascript sort function

var points = [40, 100, 1, 5, 25, 10];
points.sort((a,b) => a-b)
Posted by: Guest on May-08-2020
4

javascript sort

homes.sort((a, b) => parseFloat(a.price) - parseFloat(b.price));
Posted by: Guest on March-17-2020
-1

javascript sort

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort();
Posted by: Guest on February-09-2020

Browse Popular Code Answers by Language