티스토리 뷰
// 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
- 안드로이드
- andorid
- 화면 방향 고정
- 영문 키보드
- Android
- logcat
- kotlin
- web view
- StringWriter
- 클래스 이름
- 웹뷰
- check permissions
- new project
- javaClass
- screenorientation
- 코틀린
- permissions
- 화면 고정
- 외부 브라우저
- Inputmode
- create new project
- custom web view
- 로그캣
- web chrome view
- logtag
- simpleName
- android studio
- defaultInputmode
- create project
- web view settings
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |