3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = [ [1,3,5], [2,1,7], [3,5,9], [2,1,8] ]; $comparison = function ($a,$b) { // sort by index 1 first if($a[1] < $b[1]) return -1; if($a[1] > $b[1]) return 1; // if equal, sort by index 0 if($a[0] < $b[0]) return -1; if($a[0] > $b[0]) return 1; // otherwise sort by index 2 if($a[2] < $b[2]) return -1; if($a[2] > $b[2]) return 1; return 0; }; usort($test,$comparison); var_dump($test);

preferences:
54.7 ms | 402 KiB | 5 Q