title: How to order by desc in Apache Spark Dataset using java api?
body: <p>I'm reading a file using spark session then splitting the words and counting the iteration of the words. I need to show the data in desc order </p>
  
  <pre><code>SparkSession sparkSession = SparkSession
              .builder()
              .appName("Java Spark SQL basic example")
              .config("spark.master", "local")
              .getOrCreate();
  
  JavaRDD&lt;Word&gt; textFile = sparkSession
              .read()
              .textFile("/Users/myname/Documents/README.txt")
              .javaRDD()
              .flatMap(s -&gt; Arrays.asList(s.split("[\\s.]")).iterator())
              .map(w -&gt; {
                  Word word = new Word();
                  word.setWord(w.replace(",", ""));
                  return word;
              });
  
      Dataset&lt;Row&gt; df = sparkSession.createDataFrame(textFile, Word.class);
      df.groupBy("word").count().orderBy(org.apache.spark.sql.functions.col("count").desc()).show();
  </code></pre>
  
  <p>When I'm using <code>org.apache.spark.sql.functions.col("count")</code> it works fine but not able to do as defined in <em><a href="https://spark.apache.org/docs/2.1.1/api/java/org/apache/spark/sql/functions.html#desc(java.lang.String)" rel="nofollow noreferrer">https://spark.apache.org/docs/2.1.1/api/java/org/apache/spark/sql/functions.html#desc(java.lang.String)</a></em></p>
  
  <p><code>df.sort(asc("dept"), desc("age"))</code></p>
  
  <p>also <a href="https://stackoverflow.com/questions/30332619/how-to-sort-by-column-in-descending-order-in-spark-sql">How to sort by column in descending order in Spark SQL?</a>
  didn't work. I guess it's for scala. What is the equivalent of this in Java?</p>