Tuesday, April 14, 2009

Calling static class methods with uasort


class Testuasort
{
static function mysort($a, $b)
{
if ($a[0] == $b[0])
{
if($a[1] == $b[1]) return 0;
return $a[1] > $b[1] ? -1 : 1;
}
return $a[0] < $b[0] ? -1 : 1;
}

static function sortOnfield($narr)
{
uasort($narr, array(self,'mysort'));
return $narr;
}
}

?>

Further reading at http://bugs.php.net/bug.php?id=14104&edit=1