array_multisort
PHP 4, PHP 5, PHP 7, PHP 8
array_multisort - Sort multiple or multi-dimensional arrays
Example #1 Sorting multiple arrays
Result: array(4) {
[0]=> int(0)
[1]=> int(10)
[2]=> int(100)
[3]=> int(100)
}
array(4) {
[0]=> int(4)
[1]=> int(1)
[2]=> int(2)
[3]=> int(3)
}
Example #2 Sorting multi-dimensional array
Result: array(2) {
[0]=> array(5) {
[0]=> string(2) "10"
[1]=> int(100)
[2]=> int(100)
[3]=> int(11)
[4]=> string(1) "a"
}
[1]=> array(5) {
[0]=> int(1)
[1]=> int(3)
[2]=> string(1) "2"
[3]=> int(2)
[4]=> int(1)
}
}
Example #3 Case insensitive sorting
Result: Array
(
[0] => Alpha
[1] => atomic
[2] => bank
[3] => Beta
)
Example #4 Sorting database results
Result: volume | edition
-------+--------
67 | 2
86 | 1
85 | 6
98 | 2
86 | 6
67 | 7