snowflake.snowpark.DataFrame.order_by¶
- DataFrame.order_by(*cols: Union[Column, str, Iterable[Union[Column, str]]], ascending: Optional[Union[bool, int, List[Union[bool, int]]]] = None) DataFrame[source]¶
Sorts a DataFrame by the specified expressions (similar to ORDER BY in SQL).
When called with no column arguments, sorts by all columns (ORDER BY ALL).
Examples:
- Parameters:
*cols – Column names as
str,Columnobjects, or a list of columns to sort by. If no columns are provided, the DataFrame is sorted by all columns in the order they appear (equivalent toORDER BY ALLin SQL).ascending –
Sort order specification.
When sorting specific columns: A
bool,int, or list ofbool/intvalues.True(or 1) for ascending,False(or 0) for descending. If a list is provided, its length must match the number of columns.When sorting all columns (no columns specified): Must be a single
boolorint, not a list. Applies the same sort order to all columns.Defaults to
True(ascending) when not specified.
Note
The aliases
order_by()andorderBy()have the same behavior.