Reputation: 440
I am working in Spark & Scala and have a dataframe with several hundred columns. I would like to sort the dataframe by every column. Is there anyway to do this in Scala/Spark?
I have tried:
val sortedDf = actualDF.sort(actualDF.columns)
but .sort
does not support Array[String]
input.
This question has been asked before: Sort all columns of a dataframe but there is no Scala answer
Upvotes: 2
Views: 1085
Reputation: 440
Thank you to @blackbishop for the answer to this:
val dfSortedByAllItsColumns = actualDF.sort(actualDF.columns.map(col): _*)
Upvotes: 1