array_multisort()
function returns a sorted array. You can enter one or more arrays. The function sorts the first array first, followed by the other arrays, and if two or more values are the same, it sorts the next array.
Note: The string key name will be retained, but the numeric key name will be reindexed, starting at 0 and incrementing by 1.
Note: You can set the sort order and sort type parameters after each array. If not set, each array parameter uses the default value.
array_multisort ( array1 , sorting order , sorting type , array2 , array3 ... )
parameter | describe |
---|---|
array1 | Required. Specify array. |
sorting order |
Optional. Specify the order of arrangement. Possible values:
|
sorting type |
Optional. Specify the sorting type. Possible values:
|
array2 | Optional. Specify array. |
array3 | Optional. Specify array. |
array_multisort()
function sorts multiple arrays or multidimensional arrays.
The arrays in the parameters are treated as columns of a table and sorted by rows - this is similar to the functionality of the ORDER BY clause of SQL. The first array is the main array to be sorted. If the rows (values) in the array are compared to the same, they will be sorted according to the size of the corresponding value in the next input array, and so on.
The first parameter is an array, and each subsequent parameter may be an array, or one of the following sort order flags (the sort flag is used to change the default sort order):
You can then specify the sort type: