3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $lol = array ( 0 => array ( 'for' => '$T4', 'deps' => array ( 0 => '$T3', ), ), 1 => array ( 'for' => '$T3', 'deps' => array ( 0 => '$T2', ), ), 2 => array ( 'for' => '$T1', 'deps' => array ( ), ), 3 => array ( 'for' => '$T2', 'deps' => array ( 0 => '$T1', ), ), ); uasort($lol, function($a, $b){ return in_array($a['for'], $b['deps']) ? -1 : 1; }); print_r($lol);
based on pXIZV
Output for 7.0.0 - 7.2.0
Array ( [1] => Array ( [for] => $T3 [deps] => Array ( [0] => $T2 ) ) [2] => Array ( [for] => $T1 [deps] => Array ( ) ) [3] => Array ( [for] => $T2 [deps] => Array ( [0] => $T1 ) ) [0] => Array ( [for] => $T4 [deps] => Array ( [0] => $T3 ) ) )
Output for 5.3.20 - 5.6.28
Array ( [3] => Array ( [for] => $T2 [deps] => Array ( [0] => $T1 ) ) [1] => Array ( [for] => $T3 [deps] => Array ( [0] => $T2 ) ) [2] => Array ( [for] => $T1 [deps] => Array ( ) ) [0] => Array ( [for] => $T4 [deps] => Array ( [0] => $T3 ) ) )