scala 元组排序
_._2表示按照元组的第二个字符进行排序
前面的-号表示逆序(降序)排序,默认是升序排序
scala> List(1,2,3).sortBy(-_)
res0: List[Int] = List(3, 2, 1)
scala> List("a"->1,"b"->2, "c"->3).sortBy(-_._2)
res1: List[(String, Int)] = List((c,3), (b,2), (a,1))
scala> List(1,2,3).sortBy(x => -x)
res2: List[Int] = List(3, 2, 1)
转载自:
https://stackoverflow.com/questions/35814836/understanding-scala-code-2