Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Applies to:
Databricks SQL
Databricks Runtime
Returns the array in expr in sorted order.
Syntax
sort_array(expr [, ascendingOrder] )
Arguments
expr: AnARRAYexpression of sortable elements.ascendingOrder: An optionalBOOLEANexpression 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]