经过数小时的研究,我决定问这个问题,因为到目前为止还没有找到解决方案。我需要按属性值对多维对象进行排序,对象是多维 json 的 json_decode() 的结果,所以我需要按order
属性对以下对象进行排序:
stdClass Object
(
[main] => stdClass Object
(
[order] => 1
[size] => 100
[child] => stdClass Object
(
[c1] => stdClass Object
(
[order] => 2 // must be second item
[size] => 100
[child] => stdClass Object
(
[d1] => stdClass Object
(
[order] => 1
[size] => 100
)
)
)
[c2] => stdClass Object
(
[order] => 1, // must be first item
[size] => 100,
[child] => stdClass Object
(
[d2] => stdClass Object
(
[order] => 1
[size] => 100
)
)
)
谢谢!