I'm trying to sort a multidimensional array with an extra flag. The array got childs with name and a optional checked flag. I want to sort this array by checked, and then name. I've got this working fine on the name part, but I can't seem to get the checked flag in it.
<?php
$data = array(
array(
'name' => 'C'
),
array(
'name' => 'A'
),
array(
'name' => 'E',
'checked' => true
),
array(
'name' => 'B',
'checked' => true
),
array(
'name' => 'F'
),
array(
'name' => 'D'
)
);
usort($data, function($a, $b) {
return strcmp($a['name'], $b['name']);
});
For the record: I want this as the result: B E A C D F
Any help would be appreciated.