Re: PHP sort from a database variable..?
| From: | heilo | Date: | Wed, 04 Jun 2003 10:57:06 +0000 |
| Subject: | Re: PHP sort from a database variable..? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28295@lists.php.net to get a copy of this message | ||
wow!
thats a much more elegant way to solve this sorting problem!
didn't know usort up to now!
simple&beautiful !! :)
.ma
Ford, Mike [LSS] <M.Ford@lmu.ac.uk> wrote@04.06.2003 11:18
Uhr:
>> -----Original Message-----
>> From: heilo [mailto:grillen@abendstille.at]
>> Sent: 03 June 2003 23:35
>>
>> sorry, needed some time to hack this one ::)
>>
>> as your print_r shows that you have to sort an array which
>> includes objects
>> (in this case an ingress-class - whatever this is). i tried
>> to simulate your
>> environement and endet up with this:
>
> This looks a bit like a sledgehammer to crack a nut -- why not just use
> usort, like this:
>
> function obj_date_compare($a, $b) {
> return strcmp($a->publisertLang, $b->publisertLang);
> }
>
> ...
>
> if($ingresser = array_merge($i1 ,$i2))
> {
> $ingresser = usort($ingresser, 'obj_date_compare');
> listIngresser($ingresser);
> }
>
> Cheers!
>
> Mike
>
> ---------------------------------------------------------------------
> Mike Ford, Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS, LS6 3QS, United Kingdom
> Email: m.ford@lmu.ac.uk
> Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211