Sorting a multidimensional array

I need to sort a multidimensional array that represents the file system structure:

Array
(
    [dir1] => Array
        (
            [dir2] => Array
                (
                    [dir3] => Array
                        (
                            [dir4] => Array
                                (
                                    [0] => file1.php
                                    [1] => abc.php
                                )

                        )

                    [0] => file2.php
                    [1] => abc.php
                )

        )

    [abc] => Array
        (
            [abc] => Array
                (
                    [abc] => Array
                        (
                            [0] => file5.php
                        )

                )

        )

)

I do not know what an algorithm is.

+1
source share
1 answer

http://php.net/sort#51088

replace sort ($ a) at the beginning of the mulsort function with ksort ($ a)

EDIT: sorry, just change the mulsort code to:

function mulsort(&$a)
{
 ksort($a);
 foreach($a as &$value)
    if (is_array($value))
        mulsort($value);
}
+3
source

All Articles