3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $lol = [ ['for' => '$T4', 'deps' => ['$T3'] ], ['for' => '$T3', 'deps' => ['$T2'] ], ['for' => '$T1', 'deps' => [] ], ['for' => '$T2', 'deps' => ['$T1'] ], ]; uasort($lol, function($a, $b){ return in_array($a['for'], $b['deps']) ? -1 : 1; }); print_r($lol);
based on Bfold
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.4.10 - 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 ) ) )
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Q1GB3 on line 3
Process exited with code 255.