티스토리 뷰
// closure - sort
import UIKit
var sports = ["foot ball", "tenis", "table tenis", "wrestle", "base ball"]
sports.sort { $0 < $1 }
print(sports)
// result : ["base ball", "foot ball", "table tenis", "tenis", "wrestle"]
sports.sort { $0 > $1 }
print(sports)
// result : ["wrestle", "tenis", "table tenis", "foot ball", "base ball"]
sports.sort (by : { $0 < $1 })
print(sports)
// result : ["base ball", "foot ball", "table tenis", "tenis", "wrestle"]
sports.sort (by : { $0 > $1 })
print(sports)
// result : ["wrestle", "tenis", "table tenis", "foot ball", "base ball"]
sports.sort (by : < )
print(sports)
// result : ["base ball", "foot ball", "table tenis", "tenis", "wrestle"]
sports.sort (by : > )
print(sports)
// result : ["wrestle", "tenis", "table tenis", "foot ball", "base ball"]
sports.sort { (a, b) -> Bool in
return a < b
}
print(sports)
// result : ["base ball", "foot ball", "table tenis", "tenis", "wrestle"]
sports.sort { (a, b) -> Bool in
return a > b
}
print(sports)
// result : ["wrestle", "tenis", "table tenis", "foot ball", "base ball"]
'ios' 카테고리의 다른 글
enum : Character & String (0) | 2022.05.24 |
---|---|
short cut (0) | 2022.05.24 |
enum - case, case, case (0) | 2022.05.24 |
enum : Int (0) | 2022.05.24 |
main interface (start view) (0) | 2022.05.24 |
- Total
- Today
- Yesterday
- new project
- permissions
- 코틀린
- create new project
- 외부 브라우저
- 클래스 이름
- logtag
- logcat
- 화면 고정
- 화면 방향 고정
- check permissions
- kotlin
- 웹뷰
- 영문 키보드
- defaultInputmode
- 로그캣
- android studio
- javaClass
- custom web view
- screenorientation
- Inputmode
- web view
- StringWriter
- simpleName
- 안드로이드
- web view settings
- Android
- create project
- andorid
- web chrome view
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |