← All built-ins / sort()

sort()

sort(array &$a): bool

Parameters

NameTypeDescription
$aarrayarray to sort (by reference)

Return value

true; sorted ascending by value, re-indexed 0..n.

Example

$a = [3, 1, 2];
sort($a);
echo implode(",", $a);
1,2,3

See also

rsort()usort()asort()