daft.Expression.list.sort

daft.Expression.list.sort#

Expression.list.sort(desc: bool | daft.expressions.expressions.Expression = False, nulls_first: Optional[Union[bool, Expression]] = None) Expression[source]#

Sorts the inner lists of a list column.

Example

>>> import daft
>>> df = daft.from_pydict({"a": [[1, 3], [4, 2], [6, 7, 1]]})
>>> df.select(df["a"].list.sort()).show()
╭─────────────╮
│ a           │
│ ---         │
│ List[Int64] │
╞═════════════╡
│ [1, 3]      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ [2, 4]      │
├╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ [1, 6, 7]   │
╰─────────────╯

(Showing first 3 of 3 rows)
Parameters:

desc – Whether to sort in descending order. Defaults to false. Pass in a boolean column to control for each row.

Returns:

An expression with the sorted lists

Return type:

Expression