I know this question has been asked before, but not in this context (OOP):
class XYZ {
public function index() {
$array = [
[
'id' => 1,
'name' => 'Alpha'
],
[
'id' => 2,
'name' => 'Beta'
],
[
'id' => 3,
'name' => 'Gamma'
]
];
$newArray = usort($array, 'modify');
return $newArray;
}
public function modify($a, $b) {
return $b['name'] - $a['name'];
}
}
This indexAction returns an empty array, and I am not sure why.