c array sort function code example
Example 1: 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
Example 2: javascript sort function
var points = [40, 100, 1, 5, 25, 10];
points.sort((a,b) => a-b)