Possible to pass a closure to usort in PHP?
问题 I have an array sorting function as follows: public function sortAscending($accounts) { function ascending($accountA, $accountB) { if ($accountA['AmountUntilNextTarget'] == $accountB['AmountUntilNextTarget']) { return 0; } return ($accountA['AmountUntilNextTarget'] < $accountB['AmountUntilNextTarget']) ? -1 : 1; } usort($accounts, $ascending); return $accounts; } Clearly this is not ideal as it is hard-coding the key to search for. I thought I would make this generic by passing the key as a