Array
(
    [12] => Array
        (
            [id] => 12
            [name] => Car
            [children] => Array
                (
                    [0] => Array
                        (
                            [id] => 14
                            [name] => Volvo
                        )
                    [1] => Array
                        (
                            [id] => 15
                            [name] => Mercedes-Benz
                        )
                )
        )
    [13] => Array
        (
            [id] => 13
            [name] => Manga
            [children] => Array
                (
                    [0] => Array
                        (
                            [id] => 16
                            [name] => Naruto
                        )
                    [1] => Array
                        (
                            [id] => 17
                            [name] => Hunter X Hunter
                        )
                )
        )
    [18] => Array
        (
            [id] => 18
            [name] => aa
            [children] => Array
                (
                )
        )
)
Guys I want to sort the values of this array, i want to sort it by key and the key is 'name'. This should sort the first level and the second level thru key 'name'.
This array i put in print_r() so it looks like this. The array is not fix so i can add in the future.
So after sorting the final value of the array is...
Array
(
    [18] => Array
        (
            [id] => 18
            [name] => aa
            [children] => Array
                (
                )
        )
    [12] => Array
        (
            [id] => 12
            [name] => Car
            [children] => Array
                (
            [0] => Array
                        (
                            [id] => 15
                            [name] => Mercedes-Benz
                        )
                    [1] => Array
                        (
                            [id] => 14
                            [name] => Volvo
                        )
            )
        )
    [13] => Array
        (
            [id] => 13
            [name] => Manga
            [children] => Array
                (
            [0] => Array
                        (
                            [id] => 17
                            [name] => Hunter X Hunter
                        )
                    [1] => Array
                        (
                            [id] => 16
                            [name] => Naruto
                        )
                )
        )
)
And this is the array in code.
$categories = array(
                12 => 
                    array('id' =>12, 
                              'name' => 'Car',
                                       'children' => 
                                        array(
                                            array('id' => 14,
                                                      'name' => 'volvo'
                                            )
                                        ),
                                        array(
                                            array('id' => 15,
                                                      'name' => 'Mercedez-Benz'
                                            )
                                        )
                            ),
                13 => 
                    array('id' =>13, 
                              'name' => 'Manga',
                                       'children' => 
                                        array(
                                            array('id' => 16,
                                                      'name' => 'Naruto'
                                            )
                                        ),
                                        array(
                                            array('id' => 17,
                                                      'name' => 'Hunter X Hunter'
                                            )
                                        )
                            ),
                18=>
                    array('id' => 18, 
                              'name'=> 'aa', 
                                      'children' => array())
                );
echo "<pre>";
print_r($categories);
 
     
     
     
    