On 6 Apr 2002, at 14:38, Chris Adams wrote:

> On Sat, 6 Apr 2002 10:36:18 -0600, Peter J. Schoenster
> <[EMAIL PROTECTED]> wrote:
> > $ArrayOfNewsLinks = array(
> >   "http://dailynews.yahoo.com/fc/World/Brazil/"; => array(
> >     title => 'Yahoo Brazil News',
> >     category  => 'news',
> >     language => 'English',
> > 
> >   ),
> ...
> > function cmp ($a, $b) {
> >     if ($a[2] == $b[2]) return 0;
> >     //return strcmp ( $a[2], $b[2]); // thought this would work
> >     return ($a[1]>$b[1])?1:-1; 
> > }
> > 
> > 
> > uksort ($ArrayOfNewsLinks, "cmp");
> 
> Try changing those subscripts to keys:
> if ($a["language"] == $b["language"])
> 
> etc. You should have a ton of PHP warnings generated from the code
> above, as numeric elements won't exist.

Not running with warnings on that server (bad thing I know).

I tried the above.

uksort ($ArrayOfNewsLinks, "SortByValue");

function SortByValue ($a, $b) {
    if ($a["language"] == $b["language"]) return 0;
    return ($a["language"] > $b["language"]) ? 1 : -1; 
}


or this

function SortByValue ($a, $b) {
  return strcmp ( $a["language"], $b["language"]);
}

Doesn't work.

Peter
http://www.readbrazil.com/
Answering Your Questions About Brazil

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

Reply via email to