// 函数类型 func biggerFirst(a:Int,b:Int)->Bool { return a > b } var arr:[Int] = [] for _ in 0...50 { var ramdom = arc4random()%1000 arr.append(Int(ramdom)) } arr.sort(by: biggerFirst) // biggerFirst 作为参数传入
// 函数类型 func biggerFirst(a:Int,b:Int)->Bool { return a > b } var arr:[Int] = [] for _ in 0...50 { var ramdom = arc4random()%1000 arr.append(Int(ramdom)) } arr.sort(by: biggerFirst) // biggerFirst 作为参数传入