php sort array by specific key
usort($array, function ($a, $b) { return ($a['specific_key'] < $b['specific_key']) ? -1 : 1; });
php sort by associative array value
//php 7+ usort($inventory, function ($item1, $item2) { return $item1['price'] <=> $item2['price']; });
Source: stackoverflow.com
php sort associative array by specific value
$price = array_column($inventory, 'price'); array_multisort($price, SORT_DESC, $inventory);
Source: stackoverflow.com