I'm trying to sort a object array as per colors.
My code:
const colors = [
{
"color": "purple",
"type": true
},
{
"color": "red",
"type": false
},
{
"color": "green",
"type": true
},
{
"color": "black",
"type": false
},
{
"color": "pink",
"type": true
}]
const list = colors.sort((a) => a.color);
console.log(list);
How can I achieve this?