[英]How to sort spark dataframe on the combination of columns in Java?
groupBy() 函数在聚合期间使用,而您的要求只需要 orderBy()
假设数据帧 df 具有 3 列 Col1、Col2、Col3,您可以在 Spark 中执行以下操作
val sortedDf = df.orderBy(col("Col1").desc,col("Col2").desc,col("Col3").asc)
此处提供相同的 POC SQLFIDDLE
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.