title: Pyspark - Preserve order of collect list and collect set over multiple columns
body: <p>I have the below pyspark dataframe.</p>
  <pre><code>Column_1 Column_2 Column_3 Column_4
  1        A        U1       12345
  1        A        A1       549BZ4G
  </code></pre>
  <p>Expected output:</p>
  <p>Group by on column 1 and column 2. Collect set column 3 and 4 while preserving the order in input dataframe. It should be in the same order as input. There is no dependency in ordering between column 3 and 4. Both has to retain input dataframe ordering</p>
  <pre><code>Column_1 Column_2 Column_3 Column_4
  1        A        U1,A1    12345,549BZ4G
  </code></pre>
  <p>What I tried so far:</p>
  <p>I first tried using window method. Where I partitioned by column 1 and 2 and order by column 1 and 2. I then grouped by column 1 and 2 and did a collect set on column 3 and 4.</p>
  <p>I didn't get the expected output. My result was as below.</p>
  <pre><code>Column_1 Column_2 Column_3 Column_4
  1        A        U1,A1    549BZ4G,12345
  </code></pre>
  <p>I also tried using monotonically increasing id to create an index and then order by the index and then did a group by and collect set to get the output. But still no luck.</p>
  <p>Is it due to alphanumeric and numeric values ?
  How to retain the order of column 3 and column 4 as it is there in input with no change of ordering.</p>