Answers for "order items in array"

19

javascript sort array with objects

var array = [
  {name: "John", age: 34},
  {name: "Peter", age: 54},
  {name: "Jake", age: 25}
];

array.sort(function(a, b) {
  return a.age - b.age;
}); // Sort youngest first
Posted by: Guest on May-20-2020
-2

array sorting

/*
  Arrays Methods [Sort]
  - sort(Function [Opt])
  - reverse
*/

let myFriends = [10, "Sayed", "Mohamed", "90", 9000, 100, 20, "10", -20, -10];

console.log(myFriends);
console.log(myFriends.sort().reverse());
Posted by: Guest on July-14-2021

Code answers related to "order items in array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language