Answers for "ibrary's sort function javascript"

13

javascript sort

var names = ["Peter", "Emma", "Jack", "Mia", "Eric"];
names.sort(); // ["Emma", "Eric", "Jack", "Mia", "Peter"]

var objs = [
  {name: "Peter", age: 35},
  {name: "Emma", age: 21},
  {name: "Jack", age: 53}
];

objs.sort(function(a, b) {
  return a.age - b.age;
}); // Sort by age (lowest first)
Posted by: Guest on May-21-2020
4

javascript sort

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

Code answers related to "ibrary's sort function javascript"

Browse Popular Code Answers by Language