Let's say that I have an array of objects like so
var outer = [
{
"name": "T1",
"inner": [
{
"type": "DAY"
},
{
"type": "MONTH"
},
{
"type": "WEEKLY"
}
]
},
{
"name": "T2",
"inner": [
{
"type": "DAY"
},
{
"type": "MONTH"
},
{
"type": "WEEKLY"
}
]
}
];
I'm basically trying to sort the objects in the inner array so that the 'type' is in this order - MONTH, WEEKLY, DAY. Like this.
"inner": [
{
"type": "MONTH"
},
{
"type": "WEEKLY"
},
{
"type": "DAY"
}
]
Is there a way to do this using Lo-dash? Here's a small fiddle for this.
I saw a similar question here, but this is not exactly what I was looking for because in my case, the order will be fixed, and sort will not be based on a random string value.