In Scala, how to use Ordering[T] with List.min or List.max and keep code readable
scala
Solution
C'mon guys, you made the poor questioner find "on" himself. Pretty shabby performance. You could shave a little further writing it like this:
list min Ordering[Int].on[(_,Int)](_._2)
Which is still far too noisy but that's where we are at the moment.
Problem
In Scala 2.8, I had a need to call List.min and provide my own compare function to get the value based on the second element of a Tuple2. I had to write this kind of code: ``` val list = ("a", 5) :: ("b", 3) :: ("c", 2) :: Nil list.min( new Ordering[Tuple2[String,Int]] { def compare(x:Tuple2[String,Int],y:Tuple2[String,Int]): Int = x._2 compare y._2 } ) ``` Is there a way to make this more readable or to create an Ordering out of an anonymous function like you can do with `list.sortBy(_._2)`?