javascript sorting data code example
Example 1: javascript sort
homes.sort(function(a, b) {
return parseFloat(a.price) - parseFloat(b.price);
});
Example 2: sort js array array
var ages = [18, 21, 9, 41, 35, 24]
ages.sort(function(a, b) {
return a - b
})
// => [9, 18, 21, 24, 35, 41]