JSFiddle - React, Tailwind, and code Playground

by DenimTornado

JavaScript

function compareAge(a, b) {
  return a.b - b.b;
}

var people = [ 
  {b: 1}, 
  {b: 3}, 
  {b: 2} 
];

people.sort(compareAge);

for(var i=0; i<people.length; i++) {
  console.log(people[i].b);
}