3v4l.org

run code in 300+ PHP versions simultaneously
<?php class myClass { private $a = [ 'foo-test' => [1], '-' => [2], 'bar-test' => [3] ]; private function _mySort($x, $y) { print_r($this->a); if (!isset($this->a[$x])) { throw new Exception('Missing X: "' . $x . '"'); } if (!isset($this->a[$y])) { throw new Exception('Missing Y: "' . $y . '"'); } return ($x == 'foo-test' ? -1 : ($x == 'bar-test' ? 1 : 0)); } public function __construct() { uksort($this->a, [$this, '_mySort']); } } new myClass();

preferences:
53.18 ms | 402 KiB | 5 Q