Can anybody optimize following statement in Scala:
// maybe large val someArray = Array(9, 1, 6, 2, 1, 9, 4, 5, 1, 6, 5, 0, 6) // output a sorted list whic
For efficiency, depending on your value of large:
val a = someArray.toSet.filter(_>0).toArray java.util.Arrays.sort(a) // quicksort, mutable data structures bad :-) res15: Array[Int] = Array(1, 2, 4, 5, 6, 9)
Note that this does the sort using qsort on an unboxed array.