3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function hasort($arr) { $a = $b = array(); foreach($arr as $v => $k) $a[$k][] = $v; ksort($a); foreach($a as $v => $i) foreach($i as $k) $a[$k] = $v; return $a; } $a = array('a' => 10, 'z' => 10, 'c' => 10, 'b' => 11, 'd' => 10); $a = hasort($a); var_dump($a);
based on E0v5e
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(7) { [10]=> array(4) { [0]=> string(1) "a" [1]=> string(1) "z" [2]=> string(1) "c" [3]=> string(1) "d" } [11]=> array(1) { [0]=> string(1) "b" } ["a"]=> int(10) ["z"]=> int(10) ["c"]=> int(10) ["d"]=> int(10) ["b"]=> int(11) }