Skip to main content

OrderBy

Spark Gem

Sorts a DataFrame on one or more columns in ascending or descending order.

Parameters

ParameterDescriptionRequired
DataFrameInput DataFrame to be sortedTrue
Order columnsColumns to sort DataFrame byTrue
SortOrder of sorting - ascending or descendingTrue

Example

Example usage of OrderBy

Spark Code

def Sort(spark: SparkSession, in0: DataFrame) -> DataFrame:
return in0.orderBy(col("name").asc(), col("updated_at").desc())