passing a method to usort
| From: | chagenbu at wso dot williams dot edu | Date: | Tue, 29 Feb 2000 21:11:44 +0000 |
| Subject: | passing a method to usort | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11202@lists.php.net to get a copy of this message | ||
Should this work in php4?
<?php
error_reporting(E_ALL);
class Sort {
function cmp ($a, $b) {
if ($a == $b) return 0;
elseif ($a > $b) return 1;
else return -1;
}
}
$list = array(1, 4, 5, 2, 6, 3);
echo implode('<br>', $list);
echo '<hr>';
usort($list, 'Sort::cmp');
echo implode('<br>', $list);
?>
It seems to just ignore the function completely, and doesn't touch the list.
-chuck