I have two arrays and there information are related to index number. for instance array[5] belongs with array2[5], array[6] belongs with array2[5]... and so forth. Now i found this quick sort function at www.php.net and i'm trying to sort the first array while keeping the second array in correct. now the second array is a multidimisional array. I"m trying to figure out why my second array isn't following the swapping of the first array correctly. Please take a look. Thanks.
Ryan
function qsort_multiarray($array, &$array2, $num = 0,$left = 0,$right = -1)
{
if($right == -1)
{
$right = count($array) - 1;
}
$links = $left;
$rechts = $right;
$mitte = $array[($left + $right) / 2][$num];
if($rechts > $links)
{
do {
while($array[$links][$num]<$mitte) $links++;
while($array[$rechts][$num]>$mitte) $rechts--;
if($links <= $rechts)
{
$tmp2 = $array2[$links];
$tmp = $array[$links];
$array[$links++] = $array[$rechts];
$array2[$links] = $array2[$rechts];
$array[$rechts--] = $tmp;
$array2[$rechts] = $tmp2;
}
} while($links <= $rechts);
$array = qsort_multiarray($array,$array2, $num,$left, $rechts);
$array = qsort_multiarray($array,$array2, $num,$links,$right);
}
return $array;
}