3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = ['_', '@', ...range(-10, 10), ...range('A', 'F'), ...range('a', 'f') ]; $negatives = []; $uppers = []; $integers = []; foreach ($data as $v) { $negatives[] = $v < 0; $uppers[] = ctype_upper((string) $v); $integers[] = is_int($v); } array_multisort( $negatives, SORT_DESC, $uppers, SORT_DESC, $integers, $data ); var_export($data);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
array ( 0 => -10, 1 => -9, 2 => -8, 3 => -7, 4 => -6, 5 => -5, 6 => -4, 7 => -3, 8 => -2, 9 => -1, 10 => 'A', 11 => 'B', 12 => 'C', 13 => 'D', 14 => 'E', 15 => 'F', 16 => '@', 17 => '_', 18 => 'a', 19 => 'b', 20 => 'c', 21 => 'd', 22 => 'e', 23 => 'f', 24 => 0, 25 => 1, 26 => 2, 27 => 3, 28 => 4, 29 => 5, 30 => 6, 31 => 7, 32 => 8, 33 => 9, 34 => 10, )

preferences:
71.36 ms | 403 KiB | 91 Q