function compareAge(a, b) { return a.age - b.age; } const students = [{name: 'Sara', age:2},{name: 'John', age:1}, {name: 'Jack', age:0}]; console.log(students.sort(compareAge));