sort two arrays
Posted: Wed Apr 26, 2006 10:38 pm
have two arrays for eg
$arr1 = (1,2,4,3,5);
$arr2 = (10,2,6,19,21);
these are related, ie arr1[x] corresponds to arr2[x]..... they are x and y axis values for a graph.
the problem i have is that my x axis array is not sorted. i am drawing a line graph so i need it sorted.
sort($arr1) works like a charm!
but i want to keep the values linked. is there some type of way to simply achieve this. can i put both arrays into 1 big associative array or something?
i want to end up with
$arr1 = (1,2,3,4,5);
$arr2 = (10,2,19,6,21);........... so only swap values in arr2 that have be swapped in arr1
thanks in advance
-ards
$arr1 = (1,2,4,3,5);
$arr2 = (10,2,6,19,21);
these are related, ie arr1[x] corresponds to arr2[x]..... they are x and y axis values for a graph.
the problem i have is that my x axis array is not sorted. i am drawing a line graph so i need it sorted.
sort($arr1) works like a charm!
but i want to keep the values linked. is there some type of way to simply achieve this. can i put both arrays into 1 big associative array or something?
i want to end up with
$arr1 = (1,2,3,4,5);
$arr2 = (10,2,19,6,21);........... so only swap values in arr2 that have be swapped in arr1
thanks in advance
-ards