I am working with an Array containing objects:
$scope.items1 = [
[
{
"answer": "BARCELONA",
"idcustomer": 6,
"order": 1.1
},
{
"answer": "REAL MADRID",
"idcustomer": 6,
"order": 1.4
},
{
"answer": "LYON",
"idcustomer": 6,
"order": 1.2
},
{
"answer": "BAYERN",
"idcustomer": 6,
"order": 1.3
}
],
[
{
"answer": "BENFICA",
"idcustomer": 7,
"order": 1.2
},
{
"answer": "ARSENAL",
"idcustomer": 7,
"order": 1.4
},
{
"answer": "CITY",
"idcustomer": 7,
"order": 1.1
},
{
"answer": "UNITED",
"idcustomer": 7,
"order": 1.3
}
]
];
I have a task to extract specific values from this array and produce a new one.
The desired final result should include: - The first position representing the idcostumer. - Sorting based on the order attribute. - Including only answers with the attribute answer.
$scope.result = [
[6, "BARCELONA", "LYON", "BAYERN", "REAL MADRID"],
[7, "CITY", "BENFICA", "UNITED", "ARSENAL"]
];
https://i.sstatic.net/47oVm.png
Any help or advice on achieving this outcome would be greatly appreciated.