title: Dataframe: how to groupBy/count then order by count in Scala
body: <p>I have a dataframe that contains a thousands of rows, what I'm looking for is to group by and count a column and then order by the out put: what I did is somthing looks like :</p>
  
  <pre><code>import org.apache.spark.sql.hive.HiveContext
  import sqlContext.implicits._
  
  
  val objHive = new HiveContext(sc)
  val df = objHive.sql("select * from db.tb")
  val df_count=df.groupBy("id").count().collect()
  df_count.sort($"count".asc).show()
  </code></pre>