ARRAY_REVERSE_SORT
Function
Sort array elements in descending order.
Syntax
ARRAY_REVERSE_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 end of the returned array.
Usage notes
- If the input is
NULL, returnsNULL; if the input is an empty array[], returns an empty array. ARRAY_REVERSE_SORTsorts in descending order, whileARRAY_SORTsorts in ascending order.
Examples
-
Basic:
NULLelements are placed at the end of the returned arrayARRAY_REVERSE_SORT([1,2,3,null])->[3,2,1,null]
-
If the input is
NULL, returnsNULL; if the input is an empty array[], returns an empty array.ARRAY_REVERSE_SORT(NULL)->NULLARRAY_REVERSE_SORT([])->[]