3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { protected $val; public function __construct($val) { $this->$val = $val; } public function getVal() { return $this->val; } } $arr = array( 'one' => new test(53), 'two' => new test(200), 'three' => new test(100) ); uasort($arr, function (\test $a, \test $b) { echo 'comparing '.var_dump($a).' with '.var_dump($b); if ($a->getVal() == $b->getVal()) { return 0; } return ($a->getVal() < $b->val()) ? -1 : 1; }); print_r($arr);

preferences:
39.63 ms | 402 KiB | 5 Q