Skip to main content
VeloDB Cloud 4.x is based on Doris 3.x. Versions in this section refer to Doris versions. See Version Mapping.

ARRAY_SORT

Description​

Sort the elements in an array in ascending order

Syntax​

ARRAY_SORT(<arr>)

Parameters​

ParameterDescription
<arr>Corresponding array

Return Value​

Returns an array sorted in ascending order. If the input array is NULL, it returns NULL. If the array elements contain NULL, the output sorted array will put NULL first.

Example​

SELECT ARRAY_SORT([1, 2, 3, 6]),ARRAY_SORT([1, 4, 3, 5, NULL]),ARRAY_SORT([NULL]);
+--------------------------+--------------------------------+--------------------+
| array_sort([1, 2, 3, 6]) | array_sort([1, 4, 3, 5, NULL]) | array_sort([NULL]) |
+--------------------------+--------------------------------+--------------------+
| [1, 2, 3, 6] | [null, 1, 3, 4, 5] | [null] |
+--------------------------+--------------------------------+--------------------+