sort_array
function
Applies to: Databricks SQL Databricks Runtime
Returns the array in expr
in sorted order.
Syntax
sort_array(expr [, ascendingOrder] )
Arguments
expr
: AnARRAY
expression of sortable elements.ascendingOrder
: An optionalBOOLEAN
expression defaulting totrue
.
Returns
The result type matches expr
.
Sorts the input array in ascending or descending order according to the natural ordering of the array elements.
NULL
elements are placed at the beginning of the returned array in ascending order or at the end of the returned array in descending order.
Examples
> SELECT sort_array(array('b', 'd', NULL, 'c', 'a'), true);
[NULL,a,b,c,d]
Related functions
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for