how to sort a pandas dataframe based on a column code example
Example 1: sort a dataframe
sort_na_first = gapminder.sort_values('lifeExp',na_position='first')
Example 2: Returns a new DataFrame sorted by the specified column(s)
df.sort(df.age.desc()).collect()
df.sort("age", ascending=False).collect()
df.orderBy(df.age.desc()).collect()
from pyspark.sql.functions import *
df.sort(asc("age")).collect()
df.orderBy(desc("age"), "name").collect()
df.orderBy(["age", "name"], ascending=[0, 1]).collect()