3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = array( 3 => 2, 2 => 1, 1 => NULL, 4 => NULL, ); uasort($array, function ($a, $b) { if ($a === $b) { return 0; } elseif ($a === NULL) { return 1; } elseif ($b === NULL) { return -1; } return ($a < $b) ? -1 : 1; }); var_dump($array);
based on lZjMY
Output for 7.0.0 - 7.2.0
array(4) { [2]=> int(1) [3]=> int(2) [1]=> NULL [4]=> NULL }
Output for 5.3.20 - 5.6.28
array(4) { [2]=> int(1) [3]=> int(2) [4]=> NULL [1]=> NULL }