Sort / Array Layer
Sort elements within fixed-length arrays. Similar to Python's sorted() or R's sort(). Creates a new array column with sorted elements.
Example transformation (arrays of length 3):
arrays | sorted |
---|---|
[3, 1, 2] | [1, 2, 3] |
[c, a, b] | [a, b, c] |
[2, null, 1] | [1, 2, null] |
[null, 5, null] | [5, null, null] |
Common applications:
- Ordering values
- Rank analysis
- Sequential processing
- Data normalization
Note: Arrays must have the same fixed length across all rows. Type-specific comparison for ordering.
Table
0
0
Table
Select
columnThe fixed-length array column to sort. Arrays must contain comparable types:
- Numeric arrays: [3, 1, 2]
- String arrays: [c, a, b]
- Date arrays: [2024-01-01, 2023-12-31, 2024-02-01] All arrays must have the same length. Mixed type arrays not supported
Descending
boolSort order direction:
- false (default): ascending order (1, 2, 3)
- true: descending order (3, 2, 1)
NullsLast
boolNull value placement:
- false (default): nulls first ([null, 1, 2])
- true: nulls last ([1, 2, null])
AsColumn
nameName for the new column. If not provided, the system generates a unique name. If AsColumn
matches an existing column, the existing column is replaced. The name should follow valid column naming conventions.