So, I had to implement a case insensitive look up for a Map and I used a TreeMap to achieve this:
val treeMap = TreeMap(someOtherMap.toArray: _*)(Ordering.by(_.toLowerCase))
and treeMap.get("FOo") and treeMap.get("foo") return the same results as expected. My question is, how does the (Ordering.by(_.toLowerCase)) additional parameter help in the get()? I'm looking at the source code here and it goes RB.get(key).
How does the additional Ordering.by() exactly help in case-insensitive lookups? Does it take the lookup key, convert to lowercase, and look up keys in the Map in lowercase and then match and return the value? (Extremely naive explanation, I know but I can't seem to reason how otherwise)
New to Scala and hence trying to understand the internal workings here :)