Order by Column- What they expect?

Order by Column- What they expect?
3.0 1

#1

Hi ,

i was solving a problem and the request was something like: List the items ordered by column
Well, the output of the RDD was, by itself, ordered by column in this way: 1,2,3,4,5,6,7, …
if you apply a sortByKey or a orderBy transforming it in a dataframe it wil be sorted such as: 1,1000,1001,1002,2,2000,…

What they expect?

@itversity could you help me


#2

You need to typecast to integer and apply sortByKey to make sure data is sorted with out any issues.


#3

List the items ordered by column

val sampleList = 1 to 1000;
val rddLsit = sc.parallelize(sampleList);
val sortedRDD = rddLsit.map(x => x.toInt).sortBy(x => x)