In Scala, how to use Ordering[T] with List.min or List.max and keep code readable -


In Scala 2.8, I needed to call list.min and provide my own comparison task of a Tupal 2 The second element I had to type in this type of code:

  val list = ("a", 5) :: ("b", 3) :: ("c", 2) :: Zero List.min (New Ordering [Tupal 2 [String, Int]] {Compare Df (X: Tupal 2 [String, It], Y: Tupale 2 [String, INT]): Int = X._2 Do y._2})  

Is this a more readable Is there a way to create an order from an anonymous function or such as you list.sortBy (_._ 2) ?

Come on, guys, you've found the poor questioner "on your own" pretty awesome performance you like this You can shave a bit more to write:

  short order [int]. On [(_, int]] (_._ 2)  

which is far too loud, but that's where we are at this time.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -