Example 1 — Sort One Array
Sort a list of numbers in place.
<?php
$numbers = [3, 1, 2];
array_multisort($numbers);
echo implode(", ", $numbers), PHP_EOL; How It Works
- Create an unsorted array. It holds 3, 1 and 2.
- Call array_multisort(). It sorts
$numbersdirectly. - No assignment needed. The array is passed by reference, so the variable changes.
- Print the list. The numbers are now in ascending order.

