RE: sorting associative array

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

 



To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm



On 23 January 2005 22:37, Jeffery Fernandez wrote:

> Kurt Yoder wrote:
> 
> > Use usort (stealing from php docs):
> > 
> > 
> > 
> > function cmp($a['score'], $b['score'])

That should be:

    function cmp($a, $b)

> > {
> >    if ($a['score'] == $b['score']) {
> >        return 0;
> >    }
> >    return ($a['score'] < $b['score']) ? -1 : 1;
> > }
> > 
> > $data = array(...);
> > 
> > usort($data, "cmp");
> > 
> > 
> This won't work for me as I have 500+ records to sort based on the
> score key..

Sure it will, given the correction above.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux