https://blog.csdn.net/zhezhebie/article/details/79446817
$exampleArray1 = $exampleArray2 = array(
0 => 'example1', 1 => 'Example10', 2 => 'example12', 3 => 'Example2', 4 => 'example3', 5 => 'EXAMPLE10', 6 => 'example10' );
default sorting
asort($exampleArray1);
result:
Array
(
[5] => EXAMPLE10
[1] => Example10
[3] => Example2
[0] => example1 [6] => example10 [2] => example12 [4] => example3 )
alphanumeric with case-sensitive data sorting by values
asort($exampleArray2, SORT_STRING | SORT_FLAG_CASE | SORT_NATURAL);
result:
Array
(
[0] => example1
[3] => Example2
[4] => example3
[5] => EXAMPLE10 [1] => Example10 [6] => example10 [2] => example12 )
https://blog.csdn.net/zhezhebie/article/details/72158753 多维数组进行排序
<?php
$data = [
[
'id' => 13,
'name' => 'Arthur Dent', ], [ 'id' => 22, 'name' => 'Ford Prefect', ], [ 'id' => 5, 'name' => 'Trillian Astra', ], ]; //对多维数组进行排序,就是这么简单! // array_multisort(array_column($data, 'id'), SORT_ASC, $data); array_multisort(array_column($data, 'id'), SORT_DESC, $data); echo "<pre>"; print_r($data); echo "</pre>";