Scala sort indexedseq in place

How do you sort IndexedSeq in place in scala? Where is the API function?

+4
source share
2 answers

Currently, they are sorted out of place.

If you really need to be able to convert IndexedSeq to Array[AnyRef] and use Arrays.sort from Java (you should overlay Array[AnyRef] because Scala arrays are not covariant like Java).

Interestingly, a few weeks ago there was a discussion about adding local versions of operations such as map, filter and sort to Scala mutable collections.

I hope that after the release of additional 2.9 collections, this will be the next work item on the list to further improve the Scala collection.

It will not hurt if people raise their voice in support of this (or provide work on implementation) :-).

+6
source

If you need sorting by place, you need to use a mutable version

scala.collection.mutable.IndexedSeq

It has several sortXXX methods to use:

http://www.scala-lang.org/api/current/scala/collection/mutable/IndexedSeq.html

-1
source

All Articles