PHP Manual
Prev |  | Next

# rsort

rsort -- Sort an array in reverse order

## Description

`void rsort`(array array);

This function sorts an array in reverse order (highest to lowest).

Example 1. rsort() example

      1
      2 $fruits = array ("lemon", "orange", "banana", "apple");
      3 rsort ($fruits);
      4 for (reset ($fruits); list ($key, $value) = each ($fruits); ) {
      5     echo "fruits[$key] = ", $value, "\n";
      6 }
      7

This example would display: `fruits[0] = orange fruits[1] = lemon fruits[2] = banana fruits[3] = apple` The fruits have been sorted in reverse alphabetical order.

See also: arsort(), asort(), ksort(), sort(), and usort().

Prev | Home | Next
reset | Up | shuffle