代码如下
var numArray:[Int] = []; for _ in 0 ... 100 { numArray.append(random() % 1000) } numArray.sort({(a:Int,b:Int) -> Bool in return a > b })
// 简化闭包 let newArray = numArray.sort({a,b in a > b}) let newArray2 = numArray.sort({$0 < $1})