Arrays in PHP are "ordered maps". The "order" is internal, and has nothing to do with the numerical values of the keys.
Array_multisort() seems to sort based on this internal order. It DOES NOT maintain numeric key association, and then renumber based on this association. It maintains internal order association, and numeric keys are renumbered based on this association. String-keys do not maintain key association or internal order association, at least when mixed with numeric keys.
In other words, your 2 arrays must be built similarly or perhaps unexpected results will be obtained.
<?php
$foo=array("foo"=>"fazz", 7, 5,"sing"=>"soft", 9, 2, 0,"fing"=>"fong", 8, 1, 4);
$bar=array("bar"=>"bazz",17,45,"sing"=>"loud",29,72,90,"bing"=>"bong",38,81,54);
array_multisort($foo, $bar);
echo var_dump($foo),"<br><br>",var_dump($bar),"<br><br>";
?>
array(11) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(4) [4]=> int(5) [5]=> int(7) [6]=> int(8) [7]=> int(9) ["foo"]=> string(4) "fazz" ["fing"]=> string(4) "fong" ["sing"]=> string(4) "soft" }
array(11) { [0]=> int(90) [1]=> int(81) [2]=> int(72) [3]=> int(54) [4]=> int(45) [5]=> int(17) [6]=> int(38) [7]=> int(29) ["bar"]=> string(4) "bazz" ["bing"]=> string(4) "bong" ["sing"]=> string(4) "loud" }
<?php
$foo=array("foo"=>"fazz", 7, 5,"sing"=>"soft", 9, 2, 0,"fing"=>"fong", 8, 1, 4);
$bar=array(17,45,29,72,90,"sing"=>"loud",38,81,54,"bing"=>"bong","bar"=>"bazz");
array_multisort($foo, $bar);
echo var_dump($foo),"<br><br>",var_dump($bar),"<br><br>";
?>
array(11) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(4) [4]=> int(5) [5]=> int(7) [6]=> int(8) [7]=> int(9) ["foo"]=> string(4) "fazz" ["fing"]=> string(4) "fong" ["sing"]=> string(4) "soft" }
array(11) { [0]=> int(38) ["bar"]=> string(4) "bazz" ["sing"]=> string(4) "loud" ["bing"]=> string(4) "bong" [1]=> int(29) [2]=> int(45) [3]=> int(54) [4]=> int(90) [5]=> int(17) [6]=> int(81) [7]=> int(72) }
My Arrays in my project were built using the <?php $foo[]=$filename ?> syntax in a loop, with a string-keyed property added in at a random position within the loop to store directory names if they were found, while a matching array was built with the complete file-paths, but no directory info. Can't use Array_multisort to sort both arrays by the filenames, even after adding a "fake" matching string-keyed property to the array of filepaths after-the-fact.
I had to build my array of filepaths in a separate variable, sort, then add it to the filenames array as a string-keyed property after the fact.