List#sort List(1, 3, 2).sort(_ < _) // List(1, 2, 3) class List in scala - Scala Library Sorting.stableSort import scala.util.Sorting val ar = Array(1, 3, 2) Sorting.stableSort(ar) ar // Array(1, 2, 3) Sorting.stableSort(ar, (a: Int, b: Int) => a > b) ar // Array(3, 2, 1) import scala.collection.mutable import scala.util.Sorting val mm = mutable.Map(1 -> 70, 2 -> 50) val sorted = // sorted: Array(