Put them all into a multidim array and then order by parts.
$test=
array (
array (
'dir' => '/home',
'file' => 'file.php'
),
array (
'dir' => '/home/bubblenut',
'file' => 'another.php'
),
array (
'dir' => '/home',
'file' => 'another.php'
)
);
for($i=0;$i<count($test);$i++) {
$dir[]=&$test[$i]['dir'];
$file[]=&$test[$i]['file'];
}
array_multisort($dir, SORT_ASC, SORT_STRING, $file, SORT_ASC, SORT_STRING, $test);
$test is now
Array
(
[0] => Array
(
['dir'] => '/home',
['file'] => 'another.php'
),
[1] => Array
(
['dir'] => '/home',
['file'] => 'file.php'
)
[2] => Array
(
['dir'] => '/home/bubblenut',
['file'] => 'another.php'
)
)
of course you'd populate the arrays as you read from the directory. This may be a little overkill for what you want but I've just discovered it for a problem I was having (here)with sorting multi-dim arrays.
HTH
Bubble