Within my array, I have various objects of different types:
myArray = [
{state: "enabled", name: "zName"},
{state: "trying", name: "aName2"},
{state: "disabled", name: "aName3"},
{state: "disabled", name: "cName"},
{state: "disabled", name: "bName"}
]
My goal is to sort this array based on the following criteria:
state
equals$givenValue
name
should be arranged in ascending order for items that meet criterion 1
For instance, if I specify state == "disabled"
, the expected sorted array would be:
myArray = [
{state: "disabled", name: "aName3"},
{state: "disabled", name: "bName"},
{state: "disabled", name: "cName"},
{state: "trying", name: "aName2"},
{state: "enabled", name: "zName"}
]
Unfortunately, I'm struggling to find a solution on my own. Could you provide assistance? Thank you.