Sort by ascending type by default. To invert the order a - (Minus), you can add, as @TrustNoOne already explained.
So, sortBy(-_._2) sorted by the second value of a Tuple2 , but in reverse order.
Longer example:
scala> Map("a"->1,"b"->2, "c"->3).toList.sortBy(-_._2) res1: List[(String, Int)] = List((c,3), (b,2), (a,1))
coincides with
scala> Map("a"->1,"b"->2, "c"->3).toList sortBy { case (key,value) => - value } res1: List[(String, Int)] = List((c,3), (b,2), (a,1))
Andreas Neumann
source share