-
排序
let list = [2.3,3,6,1,-11,55,66,33,21,5,77,33]
list.sorted()
list.sorted { (a, b) -> Bool in
return a<b
}
取第一个或最后一个
-
KVC
let arr:NSArray = ["a","d","f","k","g"]
arr.value(forKeyPath: "@max.self")//k
arr.value(forKeyPath: "@min.self")//a
-
swift新方法
let arr = ["a","d","f","k","g"]
arr.max()//k
arr.min()//a
网友评论