2020-07-13 Swift3 元组比较
2020-07-13 本文已影响0人
程序员都是傻子呀
let score1 = (Chinese:90, math:95)
let score2 = (Chinese:90, math:100)
let score3 = (Chinese:100, math:90)
score1 < score2
score3 < score2
func <(t1:(Int,Int), t2:(Int,Int)) -> Bool {
if t1.1 != t2.1 { // 优先比较数学成绩
return t1.1 < t2.1
}
return t1.0 < t2.0
}