title: How to sort data in Scala?
body: <p>I have to sort data from the list but I don't know how.
  I have some code:</p>
  
  <pre><code>mailClient.messages(unreadMessages)
        .flatMap(_.files)
        .filter(filename =&gt; {
          filename._1.contains("test") &amp;&amp; filename._1.endsWith("csv")
        })
        .toList
        .sortWith((f, f1) =&gt; getFileDate(f._1).compareTo(getFileDate(f._1)))
  </code></pre>
  
  <p>and that is my next function for getDate:</p>
  
  <pre><code>def getFileDate(filename:String):LocalDate = {
      val fileParts = filename.split("_")
      val day = Integer.parseInt(fileParts(2))
      val month = Integer.parseInt(fileParts(3))
      val year = Integer.parseInt(fileParts(4))
      new LocalDate(year, month, day)
    }
  </code></pre>
  
  <p>I get date from my filename(test_03_05_2019.csv) and trying sort by this dates and got this compile error.</p>
  
  <pre><code>
  Error:(56, 14) No implicit Ordering defined for java.time.LocalDate.
        .sortBy(f =&gt; getFileDate(f._1))
  Error:(56, 14) not enough arguments for method sortBy: (implicit ord: scala.math.Ordering[java.time.LocalDate])List[(String, String)].
  Unspecified value parameter ord.
        .sortBy(f =&gt; getFileDate(f._1))
  Error:(57, 99) type mismatch;
   found   : Any
   required: String
        .map { case (filename, csv) =&gt; Source.fromString(logger.trace(s"Csv $filename content: {}", csv)) }
  </code></pre>
  
  <p>How can I do this?</p>