|
Posted by ImOk on 06/20/06 19:51
>
> $arr[0]=array('M',20000,20,'JOHN');
> $arr[1]=array('F',22000,24,'JANE');
> $arr[2]=array('M',32000,40,'JOE');
>
> function mySort($a1, $a2) {
> foreach($a1 as $i => $val) {
> if($a1[$i] < $a2[$i])
> return -1;
> if($a1[$i] > $a2[$i])
> return 1;
> }
> return 0;
> }
>
> usort($arr, 'mySort');
>
> Will sort it by the first "column", then the second, then the third,
> etc.
Good one. Now I have to fix it to do ascending, descending and up to 3
columns. I was trying to avoid this callback, but I may have no choice.
No one said life was easy.
Navigation:
[Reply to this message]
|