daft.DataFrame.sort

Contents

daft.DataFrame.sort#

DataFrame.sort(by: Union[Expression, str, List[Union[Expression, str]]], desc: Union[bool, List[bool]] = False) DataFrame[source]#

Sorts DataFrame globally

Example

>>> sorted_df = df.sort(col('x') + col('y'))
>>> sorted_df = df.sort([col('x'), col('y')], desc=[False, True])
>>> sorted_df = df.sort(['z', col('x'), col('y')], desc=[True, False, True])

Note

  • Since this a global sort, this requires an expensive repartition which can be quite slow.

  • Supports multicolumn sorts and can have unique descending flag per column.

Parameters:
  • column (Union[ColumnInputType, List[ColumnInputType]]) – column to sort by. Can be str or expression as well as a list of either.

  • desc (Union[bool, List[bool]), optional) – Sort by descending order. Defaults to False.

Returns:

Sorted DataFrame.

Return type:

DataFrame