ARRAY_SORT

Learn how to use the ARRAY_SORT array function in PlaidCloud Lakehouse. Sorts elements in the array in ascending order. Includes syntax and examples.

Sorts elements in the array in ascending order.

Analyze Syntax

func.array_sort( <array>[, <order>, <nullposition>] )
ParameterDefaultDescription
orderASCSpecifies the sorting order as either ascending (ASC) or descending (DESC).
nullpositionNULLS FIRSTDetermines the position of NULL values in the sorting result, at the beginning (NULLS FIRST) or at the end (NULLS LAST) of the sorting output.

Analyze Examples

func.array_sort([1, 4, 3, 2])

┌────────────────────────────────┐
 func.array_sort([1, 4, 3, 2])  
├────────────────────────────────┤
 [1,2,3,4]                      
└────────────────────────────────┘

SQL Syntax

ARRAY_SORT( <array>[, <order>, <nullposition>] )
ParameterDefaultDescription
orderASCSpecifies the sorting order as either ascending (ASC) or descending (DESC).
nullpositionNULLS FIRSTDetermines the position of NULL values in the sorting result, at the beginning (NULLS FIRST) or at the end (NULLS LAST) of the sorting output.

SQL Examples

SELECT ARRAY_SORT([1, 4, 3, 2]);

┌──────────────────────────┐
 array_sort([1, 4, 3, 2]) 
├──────────────────────────┤
 [1,2,3,4]                
└──────────────────────────┘