- uasort: documentation ( source)
<?php
class test {
protected $val;
public function __construct($val) {
$this->$val = $val;
}
}
$arr = array(
'one' => new test(10),
'two' => new test(1),
'three' => new test(5)
);
uasort($arr, function (test $a, test $b) {
if ($a->val == $b->val) {
return 0;
}
return ($a->val < $b->val) ? -1 : 1;
});