I have the following data structure and I'm stuck on a way to sorting all variants from all items in ascending order based on price.
Ideally I need a way to find the lowest price of any item variant while still having access to the variant's parent.
var items = [
{
"id" : 1 ,
"name" : "name1",
"variations" : [
{
"subId" : 1000011,
"subName" : "name1a",
"price" : 19.99
},
{
"subId" : 1000012,
"subName" : "name1b",
"price" : 53.21
},
{
"subId" : 1000013,
"subName" : "name1c",
"price" : 9.49
}
]
},
{
"id" : 2,
"name" : "name2",
"variations" : [
{
"subId" : 1000021,
"subName" : "name2a",
"price" : 99.29
},
{
"subId" : 1000022,
"subName" : "name2b",
"price" : 104.99
},
{
"subId" : 1000023,
"subName" : "name2c",
"price" : 38.00
}
]
}
];