I have an array of objects, each object has 2 values, priority and name.
var people = [
{
"name" : "Jim",
"priority" : "Low"
},
{
"name" : "Gary",
"priority" : "Medium"
},
{
"name" : "Andrew",
"priority" : "Medium"
},
{
"name" : "Bill",
"priority" : "High"
},
{
"name" : "Edward",
"priority" : "Medium"
}
]
I would like to sort this array, ordering by priority High to Low, and then within each priority, by name alphabetically.
Ordering alphabetically is easy enough:
people = _.orderBy(people, 'name');
But how would I sort by priority in the way I want?