title: collect_set by preserving order
body: <p>I was referring to this question <a href="https://stackoverflow.com/questions/46580253/collect-list-by-preserving-order-based-on-another-variable">Here</a>, however it works for <code>collect_list</code> and not <code>collect_set</code></p>
  
  <p>I have a dataframe like this</p>
  
  <pre><code>    data = [(("ID1", 9)), 
              (("ID1", 9)),
              (("ID1", 8)),
              (("ID1", 7)),
              (("ID1", 5)),
              (("ID1", 5))]
  df = spark.createDataFrame(data, ["ID", "Values"])
  df.show()
  
  +---+------+
  | ID|Values|
  +---+------+
  |ID1|     9|
  |ID1|     9|
  |ID1|     8|
  |ID1|     7|
  |ID1|     5|
  |ID1|     5|
  +---+------+
  </code></pre>
  
  <p>I am trying to create a new column, collecting it as <code>set</code></p>
  
  <pre><code>df = df.groupBy('ID').agg(collect_set('Values').alias('Value_set'))
  df.show()
  
  +---+------------+
  | ID|   Value_set|
  +---+------------+
  |ID1|[9, 5, 7, 8]|
  +---+------------+
  </code></pre>
  
  <p>But the order is not maintained, my order should be <code>[9, 8, 7, 5]</code></p>