title: DataFrame sql - Spark scala order by is NOT giving right order
body: <p>I have a simple dataset and I'm trying to order the elements based on the "firstname" column. I used orderby and sort in scala, but it is giving some weird output.</p>
  
  <pre><code>    scala&gt; val baseData = data.select($"Account.Number".as("AccountNumber"),
   $"Account.FirstName".as("FirstName"),
   $"Account.LastName".as("LastName"))
  
      baseData: org.apache.spark.sql.DataFrame = 
               [AccountNumber: string, FirstName: string ... 1 more field]
  
      scala&gt;  baseData.show(false)
      +-------------+---------+--------+
      |AccountNumber|FirstName|LastName|
      +-------------+---------+--------+
      |123-ABC-789  |Jay      |Smith   |
      |456-DEF-456  |Sally    |Fuller  |
      |333-XYZ-999  |Brad     |Turner  |
      |987-CBA-321  |Justin   |Pihony  |
      |123-ABC-789  |Jay      |Smith   |
      |456-DEF-456  |Sally    |Fuller  |
      |123-ABC-789  |Jay      |Smith   |
      |456-DEF-456  |Sally    |Fuller  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |987-CBA-321  |Justin   |Pihony  |
      |123-ABC-789  |Jay      |Smith   |
      |456-DEF-456  |Sally    |Fuller  |
      |333-XYZ-999  |Brad     |Turner  |
      |456-DEF-456  |Sally    |Fuller  |
      |987-CBA-321  |Justin   |Pihony  |
      |456-DEF-456  |Sally    |Fuller  |
      |456-DEF-456  |Sally    |Fuller  |
      |123-ABC-789  |Jay      |Smith   |
      +-------------+---------+--------+
      only showing top 20 rows
  
  
      scala&gt; baseData.sort($"FirstName").show(false)
      +-------------+---------+--------+
      |AccountNumber|FirstName|LastName|
      +-------------+---------+--------+
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |333-XYZ-999  |Brad     |Turner  |
      |123-ABC-789  |Jay      |Smith   |
      |123-ABC-789  |Jay      |Smith   |
      |123-ABC-789  |Jay      |Smith   |
      |123-ABC-789  |Jay      |Smith   |
      |123-ABC-789  |Jay      |Smith   |
      |123-ABC-789  |Jay      |Smith   |
      |123-ABC-789  |Jay      |Smith   |
      |123-ABC-789  |Jay      |Smith   |
      +-------------+---------+--------+
      only showing top 20 rows
  </code></pre>
  
  <p>I'm getting some repeating rows. I tried with sort and orderby, but both result in repeated rows.</p>