源数据
cat source.txt
10,20,4,335,21,20,290,19022,12232,10,1,24,58,299,600
排序后
cat result
19022
12232
600
335
299
290
58
24
21
20
实现方法
spark-shell
val N=10
val hf= sc.textFile("file:///data/spark/top10.txt")
hf.flatMap(line=>line.split(',')).map(x=>(x.toInt,null)).sortByKey(false).take(N).foreach(x=>{println(x._1))