asort
Sort an array in ascending order and maintain index association
&reftitle.description;
trueasort
arrayarray
intflagsSORT_REGULAR
Sorts array in place in ascending 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.changelog;
&Version;
&Description;
&return.type.true;
&reftitle.examples;
asort example
"lemon", "a" => "orange", "b" => "banana", "c" => "apple");
asort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val\n";
}
?>
]]>
&example.outputs;
The fruits have been sorted in alphabetical order, and the index
associated with each element has been maintained.
&reftitle.seealso;
sort
arsort
&seealso.array.sorting;