Ar Sort
Jump to navigation
Jump to search
< [[::Category:Functions|Category:Functions]]
A function added by the New Vegas Script Extender.
Description
Attempts to sort the elements of an array in ascending or descending order and returns a new regular array (list) containing the elements in sorted order (keys associated with the elements are lost, if source is a map type).
In order to be sorted all elements of an array must be of the same type (strings, numbers, or objects). If this condition is not met an empty array is returned.
Strings are sorted alphabetically and case-insensitively, numbers are sorted numerically, and objects are sorted by formID. By default the elements are sorted in ascending order, the optional flag sorts descending.
Syntax
(array) Ar_Sort Source:anyarray SortDescending:bool
Example
array_var aOriginal array_var aSorted let aOriginal := Ar_List 1, 5, 2 let aSorted := Ar_Sort aOriginal ; * 1, 2, 5 let aSorted := Ar_Sort aOriginal, 1 ; * 5, 2, 1