rsort

(PHP3 , PHP4 )

rsort -- Sort an array in reverse order

Description

void rsort (array array [, int sort_flags])

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

Példa 1. Rsort() example

  1 
  2 $fruits = array ("lemon", "orange", "banana", "apple");
  3 rsort ($fruits);
  4 reset ($fruits);
  5 while (list ($key, $val) = each ($fruits)) {
  6     echo "$key -> $val\n";
  7 }
  8       

This example would display:

  1 
  2 fruits[0] = orange
  3 fruits[1] = lemon
  4 fruits[2] = banana
  5 fruits[3] = apple
  6       

The fruits have been sorted in reverse alphabetical order.

You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort().

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