ARRAY_SORT
Function
Sort array elements in ascending order.
Syntax
ARRAY_SORT(arr)
Parameters
arr:ARRAY<T>, whereTcan be numeric, boolean, string, datetime, IP, etc.
Return value
- Returns
ARRAY<T>of the same type as the input. NULLelements are placed at the beginning of the returned array.
Usage notes
- If the input is
NULL, returnsNULL; if the input is an empty array[], returns an empty array. ARRAY_SORTsorts in ascending order, whileARRAY_REVERSE_SORTsorts in descending order.
Examples
-
Basic:
NULLelements are placed at the beginning of the returned arrayARRAY_SORT([2,1,3,null])->[null, 1, 2, 3]
-
If the input is
NULL, returnsNULL; if the input is an empty array[], returns an empty array.ARRAY_SORT(NULL)->NULLARRAY_SORT([])->[]