I have two rdd, and would like to merge together, I have the following question,
I tried the following using union, but union does not sort at all, but I don't know how to use sortby here?
List<Integer> data1 = Arrays.asList(1, 3, 5);
List<Integer> data2 = Arrays.asList(2, 4, 6, 8);
JavaRDD<Integer> rdd1 = sc.parallelize(data1);
JavaRDD<Integer> rdd2 = sc.parallelize(data2);
JavaRDD<Integer> rdd = rdd1.union(rdd2);
rdd.sortBy(w->w._1, false); //compile error
Another question, is there any good way to return the merged the list sorted?