Sure, just add ".toList.sorted" in there. Putting together in one big
expression:

val rdd = sc.parallelize(List(List(1,2,3,4,5),List(6,7,8,9,10)))
val result = 
rdd.flatMap(_.zipWithIndex).groupBy(_._2).values.map(_.map(_._1).toList.sorted)

List(2, 7)
List(1, 6)
List(4, 9)
List(3, 8)
List(5, 10)

On Tue, Aug 12, 2014 at 8:58 AM, Kevin Jung <itsjb.j...@samsung.com> wrote:
> Thanks for your answer.
> Yes, I want to transpose data.
> At this point, I have one more question.
> I tested it with
> RDD1
> List(1, 2, 3, 4, 5)
> List(6, 7, 8, 9, 10)
> List(11, 12, 13, 14, 15)
> List(16, 17, 18, 19, 20)
>
> And the result is...
> ArrayBuffer(11, 1, 16, 6)
> ArrayBuffer(2, 12, 7, 17)
> ArrayBuffer(3, 13, 18, 8)
> ArrayBuffer(9, 19, 4, 14)
> ArrayBuffer(15, 20, 10, 5)
>
> It collects well but the order is shuffled.
> Can I maintain the order?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org

Reply via email to