#DataframeMethod

Syntax: -

df.orderBy(col("column_name").asc())  # Ascending (default)
df.orderBy(col("column_name").desc())  # Descending

In PySpark, to handle ties and sort by multiple columns, use the orderBy() method with a list of columns. Specify the sorting order for each column.

df.orderBy(["col1", "col2"], ascending=[True, False]).show()