Definition
The rsort() function sorts an indexed array in descending order.
Syntax
rsort(array, sorttype)
Parameters
Parameter | Description |
---|---|
array |
Required. Specifies the array to sort. |
sorttype |
Optional. Possible values: 0 = SORT_REGULAR - Default. Compare items normally (don't change types)1 = SORT_NUMERIC - Compare items numerically2 = SORT_STRING - Compare items as strings3 = SORT_LOCALE_STRING - Compare items as strings, based on current locale4 = SORT_NATURAL - Compare items as strings using natural ordering5 = SORT_FLAG_CASE - Can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively |
Example
<?php
$cities = array("New York", "London", "Tokyo", "Berlin", "Cairo");
rsort($cities);
print_r($cities);