I have a list of objects of type A. In a first iteration I assign each object a double value 0 < x < 1 and then want to sort each object according to it\'s x value.
I go like this. For getting top c words in a hashmap:
def getTopCWordsDeclarative(input: mutable.HashMap[String, Int], c: Int): Map[String, Int] = { val sortedInput = input.toList.sortWith(_._2 > _._2) sortedInput.take(c).toMap }