array_multisort
array
[mixed$array1_sort_order = SORT_ASC],
[mixed$array1_sort_flags = SORT_REGULAR],
... mixed$rest
): bool
array_multisort can be used to sort several arrays at once, or a multi-dimensional array by one or more dimensions.
Associative (string) keys will be maintained, but numeric keys will be re-indexed.
Note:
If two members compare as equal, they retain their original order. Prior to PHP 8.0.0, their relative order in the sorted array was undefined.
Note:
Resets array's internal pointer to the first element.
Parameters
- array1
-
An array being sorted.
- array1_sort_order
-
The order used to sort the previous array argument. Either SORT_ASC to sort ascendingly or SORT_DESC to sort descendingly.
This argument can be swapped with array1_sort_flags or omitted entirely, in which case SORT_ASC is assumed.
- array1_sort_flags
-
Sort options for the previous array argument:
Sorting type flags:
SORT_REGULAR - compare items normally (don't change types)
SORT_NUMERIC - compare items numerically
SORT_STRING - compare items as strings
SORT_LOCALE_STRING - compare items as strings, based on the current locale. It uses the locale, which can be changed using setlocale
SORT_NATURAL - compare items as strings using "natural ordering" like natsort
SORT_FLAG_CASE - can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
This argument can be swapped with array1_sort_order or omitted entirely, in which case SORT_REGULAR is assumed.
- rest
-
More arrays, optionally followed by sort order and flags. Only elements corresponding to equivalent elements in previous arrays are compared. In other words, the sort is lexicographical.
Return Values
Returns true on success or false on failure.