Possible Duplicate:
How to sort the following PHP multidimensional array?
Let's say I have following array:
Array
(
[0] => Array
(
[id] => 5
[name] => Education
[parent] => 1
[sort_order] => 3
[leaf] => 1
)
[1] => Array
(
[id] => 6
[name] => Computers
[parent] => 1
[sort_order] => 1
[leaf] => 1
)
[2] => Array
(
[id] => 7
[name] => Science
[parent] => 1
[sort_order] => 2
[children] => Array
(
[0] => Array
(
[id] => 8
[name] => Mathematics
[parent] => 7
[sort_order] => 2
[children] => Array
(
[0] => Array
(
[id] => 11
[name] => Geometry
[parent] => 8
[sort_order] => 2
[leaf] => 1
)
[1] => Array
(
[id] => 12
[name] => Algebra
[parent] => 8
[sort_order] => 1
[leaf] => 1
)
)
)
[1] => Array
(
[id] => 9
[name] => Physics
[parent] => 7
[sort_order] => 1
[leaf] => 1
)
[2] => Array
(
[id] => 10
[name] => Biology
[parent] => 7
[sort_order] => 4
[leaf] => 1
)
[3] => Array
(
[id] => 13
[name] => History
[parent] => 7
[sort_order] => 3
[leaf] => 1
)
)
)
Is there any PHP built-in function which will sort this array separately on each level by 'sort_order'
value? I have found several sollutions, but all of them sorted alphabetically or have used ksort().
There will be recursion needed probably, but I need some help how to start that. TIA.