I would like to sort my List[(String, List[Int])] with respect to the second element of the tuple, including ex aqueo elements ( in fp way :) ).
The element w is greater than the element z when:
(List always have 3 ints)
For example: val c = List(("hah", List(1,1,4)), ("dd", List(4,3,2)), ("aa", List(1,2,3)), ("qw", List(1,2,3)), ("qe", List(2,1,3)), ("w", List(10,0, -9)))
Output (can be in differetnt form of course) - (Place, Tuple, Sum Of Tuple._2):
Thanks in advance!
scala> c.sortBy{ case(_, w) => (w.sum, w(0), w(2)) }.reverse
val res1: List[(String, List[Int])] = List((dd,List(4, 3, 2)), (qe,List(2, 1, 3)), (hah,List(1, 1, 4)), (qw,List(1, 2, 3)), (aa,List(1, 2, 3)), (w,List(10, 0, -9)))