title: Can you sort a mutable Scala collection in place?
body: <p>Is it possible to sort an ArrayBuffer, or other mutable Scala collection, in place? I see that ArrayBuffer.sorted (and sortBy) returns a new collection, and Sorting.quicksort does sort an Array in place but doesn't work on ArrayBuffers.</p>
  
  <p>The reason I ask is that I'm using combineByKey in Spark to build collections of scored objects that are limited in size (like a "top ten" list by key). If I merge in a new object and the collection is already at capacity, I need to drop the lowest-scored object. I could use a sorted collection like a PriorityQueue or SortedSet, but I don't need to keep the collections sorted all the time, only in the case when a collection fills up.</p>
  
  <p>So is there some way to sort an ArrayBuffer or ListBuffer in place? Or is there some other collection that supports appending and sorting in place? I'm sure there's a better way to do this, but I'm new to Scala.</p>