Sort an array using a user-defined comparison function.
Source Code
$people = [
['name' => 'John', 'age' => 30],
['name' => 'Jane', 'age' => 22],
['name' => 'Gary', 'age' => 32]
];
usort($people, function ($a, $b) {
return $a['age'] $b['age'];
});
print_r($people); // Sorted by age