Given this array:
$inventory = array(
array(\"type\"=>\"fruit\", \"price\"=>3.50),
array(\"type\"=>\"milk\", \"price\"=>2.90),
array(\"
This function is re-usable:
function usortarr(&$array, $key, $callback = 'strnatcasecmp') {
uasort($array, function($a, $b) use($key, $callback) {
return call_user_func($callback, $a[$key], $b[$key]);
});
}
It works well on string values by default, but you'll have to sub the callback for a number comparison function if all your values are numbers.