RE: PHP sort from .... best solution?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: A. Lyse [mailto:allyse@amotor.no]
> Sent: 06 June 2003 11:34

This was sent privately to me, but I'm redirecting the response back to the list in case it helps anyone else.

> Feeling kinda stupid. hehe. sorry I didnt label the lines.

Probably no more stupid than I did when I realised I'd got the usort() call wrong...!
 
> You are sure going to laught now for my stupidity, but the aricles are
> listing the wrong way (I'm a bit embarrassed now) Look here:
> http://www.amotor.no/artikler.php
> The last article: formel 1 art 4   (2003 04/06)  is dated 
> forth of june,
> 2003 and the first atricle formel 1 art 1   (2003 28/05) is dated
> twenty-eight of May, 2003. The articles in the between the 
> first and last
> article are sorting from the oldest (the first) to the newest 
> (the last). I
> guess it's not a problem to get this flipped?

No, dead simple -- simply put a - sign in the comparison function:

   function obj_date_compare($a, $b) {
      return -strcmp($a->publisertLang, $b->publisertLang);
   } 

> Sorry, for my bad English. I'm from Norway :(

Your English is fine -- if you hadn't mentioned it, I probably wouldn't have guessed that you're not a native speaker!

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 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux