title: How to Sort DataFrame with my Comparator using Scala?
body: <p>I would like to sort a DataFrame based on a column with my own comparator. It is possible to do this in Spark SQL?</p>
  
  <p>For example, let's suppose that I have a DataFrame registred as Table "MyTable" with a column "Day" which its type is "string":</p>
  
  <pre><code>id  | Day  
  --------------------
  1   | Fri           
  2   | Mon           
  3   | Sat           
  4   | Sun           
  5   | Thu           
  </code></pre>
  
  <p>And I want to execute this query:</p>
  
  <pre><code>SELECT * FROM MyTable ORDER BY Day
  </code></pre>
  
  <p>I would like to order the column "Day" with my own comparator. I thought about using a UDF but I don't know if it is possible. Note that I really want to use my comparator in Sort/Order By operations. I don't want to convert String from column Day to Datetime or something similar.</p>