I think array_multisort is supposed to do this but I couldn't get it to

Have a look at the usort call in the following routine;

// Reads a directory and puts filenames into a array sorted by date
function GetFiles ($DataPath, &$files, &$nfiles) {
  if ($handle) {
    $nfiles = 0;
    while (false!==($file = readdir($handle))) {
      if ($file != "." && $file != ".." ) {
        $files[$nfiles][name] = $file;
        $files[$nfiles][date] = filemtime($DataPath."\\".$file);
        'return $a["date"]==$b["date"]?0:($a["date"]<$b["date"]?1:-1);')


Andrew Braund

> -----Original Message-----
> From: Aaron Bennett [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 8 July 2001 17:56
> To: Php-General (E-mail)
> Subject: [PHP] Sort an array by its values
> Hi All,
>   I'm trying to sort an array of objects by the value of one of those
> objects...
> for instance, I'll have an object with 2 properties, "id" and
> "score", where
> id is unique and score is its relevant (and sometimes simelar) score. i've
> tried using sort() and asort() but i can't figure how to base the sorting
> off the value (i.e. score) of the object in the array. Any help?
> --
> Aaron

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to