I'm trying to sort my PHP hashtable based on a specific value in the inner array. The data structure looks like this:
print_r($mydata);
Array(
[0] => Array
(
[type] => suite
[name] => A-Name
)
[1] => Array
(
[type] => suite
[name] => C-Name
)
[2] => Array
(
[type] => suite
[name] => B-Name
)
)
I've tried ksort, sort, usort but nothing seems to work. I'm trying to sort based on the name key two-levels down.
This was my attempt using usort:
function cmp($a, $b) {
return $b['name'] - $a['name'];
}
usort($mydata, "cmp");
Is there an easy way to do this or do I need to write a custom sort function?