Commit dbf0fec3 authored by 高雅喆's avatar 高雅喆

add sortbykey

parent 5c395480
...@@ -654,7 +654,7 @@ object GetLevelCount { ...@@ -654,7 +654,7 @@ object GetLevelCount {
diary_level1.show() diary_level1.show()
println(diary_level1.count()) println(diary_level1.count())
val level1_count = diary_level1.rdd.map(x => (x(1).toString)).map(level1 => (level1,1)).reduceByKey((a,b) => a+b) val level1_count = diary_level1.rdd.map(x => (x(1).toString)).map(level1 => (level1,1)).reduceByKey((a,b) => a+b).map(p => (p._1,p._2)).sortByKey(false,2)
level1_count.collect() level1_count.collect()
sc.stop() sc.stop()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment