3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function cmp($a, $b) { if ($a == $b) { //return 0; } return ($a < $b) ? -1 : 1; } // Zu sortierendes Array $array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => -1, 'g' => 3, 'h' => -4, 'i' => -1); print_r($array); // Sortieren und Ausgeben des Arrays uasort($array, 'cmp'); print_r($array);
Output for 7.0.0 - 7.1.0
Array ( [a] => 4 [b] => 8 [c] => -1 [d] => -9 [e] => 2 [f] => -1 [g] => 3 [h] => -4 [i] => -1 ) Array ( [d] => -9 [h] => -4 [i] => -1 [f] => -1 [c] => -1 [e] => 2 [g] => 3 [a] => 4 [b] => 8 )
Output for 4.3.0 - 5.6.28
Array ( [a] => 4 [b] => 8 [c] => -1 [d] => -9 [e] => 2 [f] => -1 [g] => 3 [h] => -4 [i] => -1 ) Array ( [d] => -9 [h] => -4 [f] => -1 [i] => -1 [c] => -1 [e] => 2 [g] => 3 [a] => 4 [b] => 8 )