Sort break Index Ascending value sorting
Rsort Breaking index Descending value sort
Asort Keep Index Ascending value sort
Arsort Keep Index Descending value sort
Ksort Keep index Ascending key value sort (key)
Krsort Keep index Descending key value sort (key)
Usort
This function uses a user-defined comparison function to sort the values (value) in an array. This function should be used if the array to be sorted needs to be sorted with an unusual standard.
The comparison function must return an integer less than, equal to, or greater than 0, respectively, when the first argument is considered less than, equal to, or greater than the second argument.
Uksort
uksort-using a user-defined comparison function to sort the key names (keys) in the array
The cmp_function function should accept two parameters, which will be populated with a pair of key names in the array . The comparison function must return an integer less than 0, equal to zero, or greater than 0 when the first parameter is less than, equal to, or greater than the second argument.
Natsort
This function implements a sort algorithm that is similar to how people usually sort alphanumeric strings and maintains the association of the original key/value, which is called "natural ordering". This algorithm and the usual computer string sorting algorithm
bool Natcasesort (array & $array) Case insensitive
This function implements a sort algorithm that is similar to how people usually sort alphanumeric strings and maintains the association of the original key/value, which is called "natural ordering".
Returns TRUEon success, or FALSEon failure.
For example, to sort two-dimensional arrays, use the built-in functions Asort and Arsort.
The idea is to keep the keys of the $keyvalue and $arr the same, and then assign the $arr to sort the column to $keyvalue, using the built-in functions to sort the $keyvalue,
Finally, the other columns of $arr are returned based on the invariant key value.
function Array_sort ($arr, $keys, $type = ' ASC ')
{
echo ' Start sort ... '. '
';
$keysvalue = $new _array = Array ();
foreach ($arr as $k = $v)
{
$keysvalue [$k] = $v [$keys];
}
if ($type = = ' ASC ')
{
< span="">
}
Else
{
< span="">
}
Reset ($keysvalue);
foreach ($keysvalue as $k = $v)
{
$new _array[$k] = $arr [$k];
}
echo ' sort end ... '. '
';
return $new _array;
}
http://www.bkjia.com/PHPjc/750880.html www.bkjia.com true http://www.bkjia.com/PHPjc/750880.html techarticle Sort Destroy index ascending value sorts Rsort break index descending value sort Asort Keep Index ascending value sort Arsort Keep Index descending value sort Ksort Keep Index ascending key value sort ...