I have a spark pair RDD (key, count) as below
Array[(String, Int)] = Array((a,1), (b,2), (c,1), (d,3))
Using spark scala API how to get a new p
This should work:
//Assuming the pair's second type has an Ordering, which is the case for Int rdd.sortBy(_._2) // same as rdd.sortBy(pair => pair._2)
(Though you might want to take the key to account too when there are ties.)