title: Spark Dataframe - How to keep only latest record for each group based on ID and Date?
body: <p>I have a dataframe:</p>
  
  <p>DF:</p>
  
  <pre><code>1,2016-10-12 18:24:25
  1,2016-11-18 14:47:05
  2,2016-10-12 21:24:25
  2,2016-10-12 20:24:25
  2,2016-10-12 22:24:25
  3,2016-10-12 17:24:25
  </code></pre>
  
  <p>How to keep only latest record for each group? (there are 3 groups above (1,2,3)).</p>
  
  <p>Result should be:</p>
  
  <pre><code>1,2016-11-18 14:47:05
  2,2016-10-12 22:24:25
  3,2016-10-12 17:24:25
  </code></pre>
  
  <p>Trying also to make it efficient (e.g. to finish within few short minutes on a moderate cluster with 100 million records), so sorting/ordering should be done (if they are required) in most efficient and correct manner..</p>