If I have a method that has the following signature:
def max[T <% Ordered[T]](list:List[T]): T={
//return max. element of List (for example)
}
and I want to give a list of pairs like this to it:
val fu:List[Pair[String, Double]] = List(Pair("a", 3.1),Pair("b", 1.7),Pair("c", 3.1),Pair("d", 5.4))
How do I define the ordering on the second element of the list, so I am able to work with it in the function?
I tried to use
implicit def wrapper(p: Pair[String, Double])=new runtime.RichDouble(p._2)
to implicitly convert the Double of the Pair to a RichDouble which extends the ordered trait, but that is not working.