$inventory = [ ['price' => 10.99, 'product' => 'foo 1'], ['price' => 5.99, 'product' => 'foo 2'], ['price' => 100, 'product' => 'foo 3'], ]; $price = array_column($inventory, 'price'); array_multisort($price, SORT_DESC, $inventory);
$weight = [ 'Pete' => 75, 'Benjamin' => 309, 'Jonathan' => 101 ]; asort($weight); /* weight is now: Array ( [Pete] => 75 [Jonathan] => 101 [Benjamin] => 309 ) To sort descending instead use: arsort */