[javascript]
var studs = [{name: 'clap ', age: 15},
{name: 'martin', age: 13},
{name: 'merry', age: 10}];
function sortbyage(a, b )
{
// Sort by age from smallest to largest
return a.age > b.age;
}
function sortbyname(a, b)
{
return a.name > b.name;
}
//Sort by age
studs.sort(sortbyage);
for(var i = 0; i < ; studs.length; i )
console.log(studs[i]);
//Sort by name
studs.sort(sortbyname);
for(var i = 0 ; i < studs.length; i )
console.log(studs[i]);