已采纳回答 / 小大熊猫
如果要有序可以很多种办法。1. 换用数组,2. 换一个有序index做key,3:for i in "赤橙黄绿青蓝紫"{ color[i]}不过这时候就要用 “赤橙黄绿青蓝紫”来做key了
2015-05-14
var 字符数组 = ["d","cd","bcd","abcd","abc","ab","a"]
sorted(字符数组, {count($0) == count($1) ? $0 < $1 : count($0) < count($1)})
sorted(字符数组, {count($0) == count($1) ? $0 < $1 : count($0) < count($1)})
2015-05-08
var 字符数组 = ["d","cd","bcd","abcd","abc","ab","a"]
sorted(字符数组, {(n1:String,n2:String)->Bool in
return count(n1) == count(n2) ? n1 < n2 : count(n1) < count(n2)
}
)
sorted(字符数组, {(n1:String,n2:String)->Bool in
return count(n1) == count(n2) ? n1 < n2 : count(n1) < count(n2)
}
)
2015-05-08
声明函数:swap( inout a:Int , inout b:Int )
调用: swap(&x , &y)
调用: swap(&x , &y)
2015-05-05