Sort () Definition and usage
The sort () function sorts the values of the given array in ascending order.
Note: This function assigns the new key name to the cells in the array. The original key name is deleted.
Returns TRUE if successful, otherwise FALSE.
Grammar
Sort (array,sorttype) parameter description
Array required. The input array.
SortType is optional. Specifies how the values of the array are arranged. Possible values:
Sort_regular-Default. Processed in their original type (without changing the type).
Sort_numeric-Handle the value as a number
Sort_string-handles the value as a string
Sort_locale_string-handles the value as a string, based on local settings *.
*: This value is new for PHP 4.4.0 and 5.0.2. Prior to PHP 6, the system's locale was used, which can be changed using setlocale (). From PHP 6, you must use the I18n_loc_set_default () function.
Example
<?php $my _array = Array ("A" = "Dog", "b" = "Cat", "c" = "Horse"); Sort ($my _array); Print_r ($my _array);?>
Output:
Array ([0] = Cat [1] = Dog [2] = = Horse)