3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Point { public function __construct( private int $y, private int $x, private string $debug, ) {} } // Order is intended to be like ORDER BY x, y // Because the order properties are declared, it becomes ORDER BY y, x $data = [ new Point(3,1,'should be third'), new Point(1,1,'should be first'), new Point(1,2,'should be fourth'), new Point(2,1,'should be second'), ]; sort($data); print_r($data);
Output for 8.1.29 - 8.1.30, 8.2.20 - 8.2.24, 8.3.5 - 8.3.12
Array ( [0] => Point Object ( [y:Point:private] => 1 [x:Point:private] => 1 [debug:Point:private] => should be first ) [1] => Point Object ( [y:Point:private] => 1 [x:Point:private] => 2 [debug:Point:private] => should be fourth ) [2] => Point Object ( [y:Point:private] => 2 [x:Point:private] => 1 [debug:Point:private] => should be second ) [3] => Point Object ( [y:Point:private] => 3 [x:Point:private] => 1 [debug:Point:private] => should be third ) )

preferences:
41.75 ms | 408 KiB | 5 Q