- print_r: documentation ( source)
- usort: documentation ( source)
<?php
class Foo {
protected function order($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
public function sortStuff($arr) {
usort($arr, [$this, 'order']);
return $arr;
}
}
$f = new Foo();
print_r($f->sortStuff([5, 6, 8, 3, 7, 9]));