This is an old revision of the document!
Sort an Array.
Syntax
Parameters
subject
- The Array to sort.reverse
- Whether to reverse the sort.false
(default) - subject
will be sorted from lowest to highest.true
- subject
will be sorted from highest to lowest.type
- Array key options.0
(default) - Sort by item values, and re-assign keys.1
- Sort by item values, and preserve keys.2
- Sort by item keys.method
- Sort method options.0
(default) - Compare items normally, without changing type.1
- Compare items numerically.2
- Compare items as strings.3
- Compare items as strings, using case-sensitive natural ordering.4
- Compare items as strings, using case-insensitive natural ordering.5
- Compare items as strings, based on the current system locale.
Result
Returns subject
sorted in order according to various options.
Natural ordering cannot be used with key preservation (when type
is 1
) or sorting by key (when type
is 2
), so type
will be forced to 0
in this case.
~~DISCUSSION~~