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; }); var_dump($lol);
Output for 7.0.0 - 7.2.0
array(4) { [1]=> array(2) { ["for"]=> string(3) "$T3" ["deps"]=> array(1) { [0]=> string(3) "$T2" } } [2]=> array(2) { ["for"]=> string(3) "$T1" ["deps"]=> array(0) { } } [3]=> array(2) { ["for"]=> string(3) "$T2" ["deps"]=> array(1) { [0]=> string(3) "$T1" } } [0]=> array(2) { ["for"]=> string(3) "$T4" ["deps"]=> array(1) { [0]=> string(3) "$T3" } } }
Output for 5.3.20 - 5.6.28
array(4) { [3]=> array(2) { ["for"]=> string(3) "$T2" ["deps"]=> array(1) { [0]=> string(3) "$T1" } } [1]=> array(2) { ["for"]=> string(3) "$T3" ["deps"]=> array(1) { [0]=> string(3) "$T2" } } [2]=> array(2) { ["for"]=> string(3) "$T1" ["deps"]=> array(0) { } } [0]=> array(2) { ["for"]=> string(3) "$T4" ["deps"]=> array(1) { [0]=> string(3) "$T3" } } }