2
val data :Seq[Something] = ...
val transformed = data.par.map transform toList
val sorted = transformed.sortWith(...)

How can I get rid of the toList when sorting par sequences?

User1291
  • 7,664
  • 8
  • 51
  • 108

1 Answers1

1

If you're asking whether there is a parallel sorting implementation for parallel collections in the standard library, the answer is no. If you just want to get rid of the toList, I suggest .seq.

In terms of performance, there i no penalty to go from a parallel collection to a seq. Take a look here for more detail. Also if you check at the implementation you can see that .seq returns the arrayseq which is the main structure storing the elements in the ParArray, without any modification.

Community
  • 1
  • 1
Kim Stebel
  • 41,826
  • 12
  • 125
  • 142
  • 1
    So there really is no way to sort without transforming? Sucks. Does `.seq` offer any benefits over `.toList` (e.g. time)? – User1291 Jun 06 '15 at 10:00