3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['id' => 1, 'position' => 7], ['id' => 3, 'position' => 2], ['id' => 2, 'position' => 1], ['id' => 4, 'position' => 4], ]; usort($arr, function ($a, $b) { return $a['position'] > $b['position'] ? 1 : -1; }); print '<pre>'; print_r($arr);
Output for 7.1.25 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
<pre>Array ( [0] => Array ( [id] => 2 [position] => 1 ) [1] => Array ( [id] => 3 [position] => 2 ) [2] => Array ( [id] => 4 [position] => 4 ) [3] => Array ( [id] => 1 [position] => 7 ) )

preferences:
143.38 ms | 404 KiB | 178 Q