ARRAY_REVERSE_SORT
Function
Sort array elements in descending order.
Syntax
ARRAY_REVERSE_SORT(arr)
Parameters
arr
:ARRAY<T>
, whereT
can be numeric, boolean, string, datetime, IP, etc.
Return value
- Returns
ARRAY<T>
of the same type as the input. NULL
elements 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_SORT
sorts in descending order, whileARRAY_SORT
sorts in ascending order.
Examples
-
Basic:
NULL
elements 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)
->NULL
ARRAY_REVERSE_SORT([])
->[]