$data = [
[ 'parent'=> 1, 'id' => 4, 'data' => 'empat', ],
[ 'parent'=> 4, 'id' => 2, 'data' => 'dua', ],
[ 'parent'=> 0, 'id' => 3, 'data' => 'tiga' ],
[ 'parent'=> 3, 'id' => 1, 'data' => 'satu' ]
];
$sorted = array_orderby('id', 'parent', $data);
print_r($sorted);
Array
(
[0] => Array
(
[parent] => 0
[id] => 3
[data] => tiga
)
[1] => Array
(
[parent] => 3
[id] => 1
[data] => satu
)
[2] => Array
(
[parent] => 1
[id] => 4
[data] => empat
)
[3] => Array
(
[parent] => 4
[id] => 2
[data] => dua
)
)