CKTIS / PHP
rsort()
Sort values from high to low in place and assign new integer keys from zero.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
rsort(array &$array, int $flags = SORT_REGULAR): trueSort values from high to low in place and assign new integer keys from zero. SORT_NUMERIC compares numeric magnitudes. The function returns true, and using it on a named ranking discards the original labels.
Signature
rsort(array &$array, int $flags = SORT_REGULAR): true
Example output
[true,["12","5","2"]]
Examples
<?php
$times = ["a"=>"2","b"=>"12","c"=>"5"];
$ok = rsort($times,SORT_NUMERIC);
echo json_encode([$ok,$times]);
Result
[true,["12","5","2"]]