|
Posted by Michael Fesser on 10/16/07 18:05
..oO(Paul)
>"ZeldorBlat" <zeldorblat@gmail.com> schreef in bericht
>news:1192478692.496334.152780@v29g2000prd.googlegroups.com...
>>
>> Something like this (untested):
>>
>> usort($a, create_function('$a1,$a2', 'return $a1["number of messages"]
>> - $a2["number of messages"];'));
>>
>Thanks. My solution:
>usort ($a, "mysort");
>function mysort ($a, $b) {
> if ($a['number of messages']<$b['number of messages']) return -1;
> else if ($a['number of messages']>$b['number of messages']) return 1;
> return 0;
>}
JFTR: I would drop the if-else and simply return the difference between
both values as in ZeldorBlat's function. The comparison function doesn't
necessarily have to return exactly -1, 0 or 1, the return value just has
to be lower than, equal to or greater than zero.
Micha
Navigation:
[Reply to this message]
|