这章学的不是很透彻,需要再次学习
<span style="font-size:18px;">
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]
// func backwards(s1: String, s2: String) -> Bool {
// return s1 > s2
// }
// var reversed = sort(names, backwards)
//1.闭包
var reversed = sort(names, { (s1: String, s2: String) -> Bool in
return s1 > s2
})
//2.根据上下文推断
reversed = sort(names, { s1, s2 in return s1 > s2 } )
//3.参数名缩写
reversed = sort(names, { $0 > $1 } )
//4.运算符函数
reversed = sort(names, >)
println(reversed)
}
</span>