Created
October 24, 2013 12:07
-
-
Save debasishg/7136051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> List("a", "b", "AA", "d") | |
| res0: List[String] = List(a, b, AA, d) | |
| // List.sortBy, List.sorted and TreeMap all take an implicit scala.math.Ordering | |
| // just define the following at the top of StorageRepoQueries | |
| scala> object CaseInsensitiveOrdering extends Ordering[String] { | |
| | def compare(a: String, b: String) = a.toLowerCase compare b.toLowerCase | |
| | } | |
| defined module CaseInsensitiveOrdering | |
| // and pass the Ordering object in all places we call sort or create a TreeMap | |
| scala> res0.sorted(CaseInsensitiveOrdering) | |
| res6: List[String] = List(a, AA, b, d) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment