ASORT†
Format†
ASORT( option , array )
Function†
- Sort data in a general purpose array in the specified order.
Arguments†
- option
- Sorting options (string). See below.
- array
- A general purpose array (simple arrays cannot be used).
About options†
Comparison type
- string
- Treats all data as strings and arranges them in character code order [default if nothing is specified].
- int
- Treats all data as integers and arranges them in numerical order of size.
- double
- Treats all data as real numbers and arranges them in numerical order of size.
- length
- Used in conjunction with the string specification, the length of the string is used to determine the order, not the content of the string.
Order
- ascending
- Sort data in ascending order (1,2,3...) [default if nothing is specified].
- descending
- Sort data in descending order (...3,2,1).
Return format
- index
- This does not return the sorted array itself, but rather an array of "what position the sorted items will be after sorting".
For example, if you sort 'Z','G','A' in ascending string order, the order should be A,G,Z, so the integer array 2,1,0 is returned.
The three types of specifications above are separated by commas. See the examples for details.
Return value†
- The general purpose array that has been sorted.
- In the case of an error or if an empty general purpose array is passed in, it will be an empty general purpose array.
Related†
Version†
- YAYA: Tc540-1
- index option available from Tc545-1 and on
Example†
_array = ('BBBB','CCC','AA') // Assign a general purpose array
ASORT('string,ascending', _array) // "AA,BBBB,CCC" is output
ASORT('string,descending,length', _array) // "BBBB,CCC,AA" is output