任何人都可以在Scala中优化以下语句:
// maybe large
val someArray = Array(9, 1, 6, 2, 1, 9, 4, 5, 1, 6, 5, 0, 6)
// output a sorted list which contains unique element from the array without 0
val newList=(someArray filter (_>0)).toList.distinct.sort((e1, e2) => (e1 > e2))
Run Code Online (Sandbox Code Playgroud)
由于性能至关重要,有更好的方法吗?
谢谢.