通过键的存在对多维数组进行排序

I have array:

Array (
    [0] => Array (
        [var_for_type] => inside
        [show_about] => on
        [pagethumb] => on
        [postthumb] => on
        [portfoliothumb] => on
    )
    [1] => Array (
        [var_for_type] => shadow
        [show_about] => on
        [box_for_type] => Array ( [0] => cvb [1] => odf [2] => o-koshkah )
        [postthumb] => on
    )
)

And I need to sort it by existence of key 'box_for_type'. If key 'box_for_type' exists, than output it before other arrays in multidimensional array. How can I do it?

You need to use usort() function where you can define your own function for comparing elements:

 $sample = [
   ['test' => 'a'],
   ['test' => 'g', 'box_for_type' => []],   
   ['test' => 'b'],
   ['test' => 'c', 'box_for_type' => []],
 ];


usort($sample, function ($a, $b){
   return (int)!array_key_exists('box_for_type', $a); 
});

print_r($sample);