arsort
Sort an array in descending order and maintain index association
&reftitle.description;
boolarsort
arrayarray
intflagsSORT_REGULAR
Sorts array in place in descending order,
such that its keys maintain their correlation with the values they
are associated with.
This is used mainly when sorting associative arrays where the actual
element order is significant.
¬e.sort-unstable;
¬e.reset-index;
&reftitle.parameters;
array
The input array.
&sort.flags.parameter;
&reftitle.returnvalues;
&return.true.always;
&reftitle.examples;
arsort example
"lemon", "a" => "orange", "b" => "banana", "c" => "apple");
arsort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?>
]]>
&example.outputs;
The fruits have been sorted in reverse alphabetical order, and
the index associated with each element has been maintained.
&reftitle.seealso;
sort
asort
&seealso.array.sorting;