I have a json with this schema
{
"foo":"foo1",
"bar":"bar1",
"fields":[
{
"foo":"foo2",
"bar":"bar2",
"fields":[
{
"foo":"foo3",
"bar":"bar"3,
"count":32
},
{
"foo":"foo4",
"bar":"bar4",
"count":2
}
],
"count":42
},
],
"count":2
}
I need to sort and order the items recursively so to produce a "top ten". Let's say, in this case, I have to find a "top two", that is the two items having the higher 'count' at any level. It is possibile with the php native sorting functions?
The return item is not really important. Let's say it must return the "foo" element so that, in this example case, the result could be:
foo2
foo3
And if the count where all the same (all count:1) it should return the first two encountered like
foo1
foo2