Notice
Recent Posts
Recent Comments
Link
반응형
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- NSURLErrorDomain Code=-1022
- 성능효율성
- Linux
- swiftui keyboard
- Alamofire
- sudo docker
- swiftm
- Apple Silicon
- 6pillar
- well architected
- Swift
- aws database
- perfomance efficiency
- 가상머신
- AppTransportSecurity
- SwiftUI
- Arm
- service key is not registered error
- m4
- ssh-remote
- ubuntu-desktop
- codingkey
- M3
- api service key error
- ubuntu
- Docker Engine
- M1
- Alamofire.AFError.session Task Failed(error: Error Domain=NSURLErrorDomain Code=-1022
- M2
- swiftui keyboard dismiss
Archives
- Today
- Total
behan의 개인적인 기술 블로그
Swift) 구조체배열 정렬 본문
반응형
swift sort()를 사용한 struct 정렬 방법
[구조체]
struct CommonCode {
let sgId: String
let sgName: String
}
var commoncodes: [CommonCode] = [...]

- sort() v.s sorted()
sort()는 적용되는 배열 자체를 정렬
sorted()는 정렬된 배열을 리턴(본 배열은 그대로)
사용법
sortedArray = commoncodes.sorted { lhs, rhs in
return lhs.sgId < rhs.sgId
}
commoncodes.sort { lhs, rhs in
return lhs.sgId < rhs.sgId
}
or
sortedArray = commoncodes.sorted { $0.sgId < $1.sgId }
commoncodes.sort { $0.sgId < $1.sgId }반응형
'iOS > Swift' 카테고리의 다른 글
| Swift) Alamofire Router, Combine 사용 (0) | 2022.02.02 |
|---|---|
| Swift) SQLite 사용법 (0) | 2022.01.20 |
| Swift) 공공데이터 API serviceKey 에러 (feat. SERVICE_KEY_IS_NOT_REGISTERED_ERROR) (0) | 2022.01.13 |
| Swift) json 파싱 항목명을 다른 이름으로 사용 (feat. Codingkey) (0) | 2022.01.12 |