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

    $fruits = array("lemon","orange","banana","apple");
    rsort($fruits);
    for(reset($fruits); $key = key($fruits); next($fruits)) {
        echo "fruits[$key] = ".$fruits[$key]."\n";
    }
	
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().