package sparkcore.java;
import java.util.Arrays;
import java.util.Iterator;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.FlatMapFunction;
import org.apache.spark.api.java.function.Function2;
import org.apache.spark.api.java.function.PairFunction;
import org.apache.spark.api.java.function.VoidFunction;
import scala.Tuple2;
/**
* 排序的wordcount程序:根据单词出现的次数进行排序
*/
public class SortWordCount {
public static void main(String[] )
val ) }
val wordCounts = pairs.reduceByKey(_ + _)
val countWords = wordCounts.map(wordCount => (wordCount._2, wordCount._1))
val sortedCountWords = countWords.sortByKey(false)
val sortedWordCounts = sortedCountWords.map(sortedCountWord => (sortedCountWord._2, sortedCountWord._1))
sortedWordCounts.foreach(sortedWordCount => println(sortedWordCount._1 + " : " + sortedWordCount._2))
}
}