// Sort Ascending - both the 2 below yeild same results
gGraph.inDegrees.collect.sortBy(_._2).take(10)
gGraph.inDegrees.collect.sortWith(_._2 < _._2).take(10)
// Sort Decending
gGraph.inDegrees.collect.sortWith(_._2 > _._2).take(10)
gGraph.inDegrees.collect.sortBy(_._2, ascending=false).take(10) //Doesnt Work!!
내가 sortBy(_._2, ascending=false)
의 결과를 기대 (스칼라를 사용하여) 스파크 그래프에에 -도에 기반 정점 목록을 정렬하는 것을 시도하고있다 위에서 언급 한 sortWith(_._2>_._2)
과 동일해야합니다. 하지만 아래 오류가 발생했습니다. 이 문제에 대한 어떤 생각을 감사하십시오. 감사!
scala> gGraph.inDegrees.collect.sortBy(_.2, ascending=false).take(10) :55: error: too many arguments for method sortBy: (f: ((org.apache.spark.graphx.VertexId, Int)) => B)(implicit ord: scala.math.Ordering[B])Array[(org.apache.spark.graphx.VertexId, Int)] gGraph.inDegrees.collect.sortBy(._2, ascending=false).take(10)
예, 작동합니다. 감사! 스칼라> gGraph.inDegrees.sortBy (_._ 2, 오름차순 = false) .take (10) res122 : Array [(org.apache.spark.graphx.VertexId, Int)] = 배열 ((10397,152), ((1128, 132), (12266,107), (13487,96), (12892,82), (11618,82), (11433,81), (14869, 80)) – DanJoe