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):

arrayssorted
[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

column

The 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
false

Sort order direction:

  • false (default): ascending order (1, 2, 3)
  • true: descending order (3, 2, 1)
false

Null value placement:

  • false (default): nulls first ([null, 1, 2])
  • true: nulls last ([1, 2, null])

Name 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.