How this sort array example works
PHP sort functions modify the array in place and return true. sort()/rsort() re-index the array, asort()/arsort() sort by value but keep keys, and ksort()/krsort() sort by key.
Custom sorting with usort() and the spaceship operator
<?php
$people = [["name" => "Ann", "age" => 25], ["name" => "Bob", "age" => 41], ["name" => "Cy", "age" => 33]];
usort($people, fn($a, $b) => $b["age"] <=> $a["age"]);
echo implode(", ", array_column($people, "name"));
Output:
Bob, Cy, Ann