title: How to maintain the order of the data while selecting the distinct values of column from Dataset
body: <p>I have a Dataset as below,</p>
  
  <pre><code>+------+------+---------------+
  | col1 | col2 |  sum(costs)   |
  +------+------+---------------+
  |    1 | a    | 3555204326.27 |
  |    4 | b    | 22273491.72   |
  |    5 | c    | 219175.00     |
  |    3 | a    | 219175.00     |
  |    2 | c    | 75341433.37   |
  +------+------+---------------+
  </code></pre>
  
  <p>I need to select the distinct values of the col1 and my resultant dataset should have the order as 1, 4, 5, 3, 2 (the order in which these values are available in initial dataset). But the order is getting shuffled. Is there any way to maintain the same order as the intital dataset. Any suggestion in Spark/SQL could be fine.</p>
  
  <p>This dataset can be obtained by below sequence in spark.</p>
  
  <pre><code>df = sqlCtx.createDataFrame(
    [(1, a, 355.27), (4, b, 222.98), (5, c, 275.00), (3, a, 25.00),
     (2, c, 753.37)], ('Col1', 'col2', 'cost'));
  </code></pre>