|
Posted by Ewoud Dronkert on 11/26/05 18:14
Joe wrote:
> As I see it it can sort the values but doesn't keep the personid fixed to
> the salary.
Is that important? I don't know. I mean, where's the real data? He only
showed us the keys of a 2D array. Very weird to use salary as the 2nd key!
And, is there only one index value for each personid??
So, use uasort instead of usort:
function cmp($a, $b) {
list($k1,) = each($a);
list($k2,) = each($b);
return $k1 - $k2;
}
uasort($person, 'cmp');
Or:
$k = array_keys($person);
foreach ( $k as $i )
list($salary[$i],) = each($person[$i]);
asort($salary);
--
E. Dronkert
Navigation:
[Reply to this message]
|