scala> val arr = Array(1, 2, 3, 4, 5, -1, 6,0, -2, 7, -3, 8, -4, 9,0, -5)
arr: Array[Int] = Array(1, 2, 3, 4, 5, -1, 6, 0, -2, 7, -3, 8, -4, 9, 0, -5)
scala> val ap = arr.filter(_ > 0)
ap: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
scala> val arr1 = ap ++ arr.diff(ap)
arr1: Array[Int] = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, -1, 0, -2, -3, -4, 0, -5)
原文:http://blog.51cto.com/12211918/2066692