Scala/Sort: Refactor