|
sortSort an array Description
bool sort
( array
&$array
[, int $sort_flags = SORT_REGULAR
] )This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.
Parameters
Return Values
Returns Changelog
Examples
Example #1 sort example
<?php The above example will output: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange The fruits have been sorted in alphabetical order.
Example #2 sort example using case-insensitive natural ordering
<?php The above example will output: fruits[0] = Orange1 fruits[1] = orange2 fruits[2] = Orange3 fruits[3] = orange20 The fruits have been sorted like natcasesort. Notes
Warning
Be careful when sorting arrays with mixed types values because sort can produce unpredictable results. |