title: Orderby date column PySpark
body: <p>I have a dataset like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Title</th>
  <th style="text-align: center;">Date</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">The Last Kingdom</td>
  <td style="text-align: center;">19/03/2022</td>
  </tr>
  <tr>
  <td style="text-align: left;">The Wither</td>
  <td style="text-align: center;">15/02/2022</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to create a new column with only the month and year and order by it. 19/03/2022 would be 03-2022</p>
  <p>I created the column like this:</p>
  <pre><code>netflix_df = (netflix_df
                   .withColumn('month', F.substring(F.col(&quot;Date&quot;), 4, 9))
                   .withColumn(&quot;month&quot;, F.regexp_replace(F.col(&quot;month&quot;), '/', '-'))
                 )
  </code></pre>
  <p>Resulting in:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">Title</th>
  <th style="text-align: center;">Date</th>
  <th style="text-align: center;">month</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">The Last Kingdom</td>
  <td style="text-align: center;">19/03/2022</td>
  <td style="text-align: center;">03-2022</td>
  </tr>
  <tr>
  <td style="text-align: left;">The Wither</td>
  <td style="text-align: center;">15/02/2022</td>
  <td style="text-align: center;">02-2022</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>But when I do:</p>
  <pre><code>display(netflix_df.orderBy(F.col(&quot;month&quot;)))
  </code></pre>
  <p>Gives the error:</p>
  <pre><code>ClassCastException: java.lang.Long cannot be cast to java.lang.String
  </code></pre>