There is a DataFrame as following:
import spark.implicits._ val df = List( ("id1","blue","1") ,("id2","red","2") ,("id3","red","3") ,("id4","blue","3") ,("id4","green","3") ).toDF("id", "color", "size") +---+-----+----+ | id|color|size| +---+-----+----+ |id1| blue| 1| |id2| red| 2| |id3| red| 3| |id4| blue| 3| |id4|green| 3| +---+-----+----+ There is a Seq[org.apache.spark.sql.Column] and it can sort df as following:
import org.apache.spark.sql.Column val col = Seq(new Column("size"), new Column("color")) df.sort(col:_*).show But I want to sort by col with descending order.
import org.apache.spark.sql.functions.desc df.sort(desc(col:_*)) does not work.
Then how to sort df by col in descending order?
asc/descfor sorting on individual columns, like,val col = Seq(new Column("size").asc, new Column("color").desc).