3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ [6,3,9], [9,1,6], [4,7,9] ]; echo "input array: "; print_r($input); $sort_keys = $input[0]; asort($sort_keys); $sorted = array_map(function($row) use ($sort_keys){ foreach ($sort_keys as $key => $value) { $result[] = $row[$key]; } return $result; }, $input); echo "sorted array: "; print_r($sorted);

preferences:
54.45 ms | 402 KiB | 5 Q