var fruits = [
{ fruit: "apple", color: "red" },
{ fruit: "orange", color: "orange" },
{ fruit: "cherry", color: "red" },
{ fruit: "grape", color: "green" },
{ fruit: "strawberry", color: "red" },
{ fruit: "lemon", color: "yellow" },
{ fruit: "peach", color: "yellow" },
{ fruit: "kiwi", color: "green" },
{ fruit: "lime", color: "green" }
];
fruits.sort(function(a, b){
var colorA=a.color.toLowerCase(), colorB=b.color.toLowerCase()
if (colorA < colorB)
return -1
if (colorA > colorB)
return 1
return 0
})
console.log(fruits);
fruits.sort(function(a, b){
var fruitA=a.fruit.toLowerCase(), fruitB=b.fruit.toLowerCase()
if (fruitA < fruitB)
return -1
if (fruitA > fruitB)
return 1
return 0
})
console.log(fruits);