sort object by property array contains swift code example
Example 1: javascript sort
var names = ["Peter", "Emma", "Jack", "Mia", "Eric"];
names.sort();
var objs = [
{name: "Peter", age: 35},
{name: "Emma", age: 21},
{name: "Jack", age: 53}
];
objs.sort(function(a, b) {
return a.age - b.age;
});
Example 2: arr.sort
var fruitSalad = ['cherries', 'apples', 'bananas'];
fruit.sort();
var scores = [1, 10, 2, 21];
scores.sort();
var randomThings = ['word', 'Word', '1 Word', '2 Words'];
randomThings.sort();