Daeng iOS

[iOS/Swift] Model 안의 멤버변수로 배열 정렬하기 본문

IOS/Swift

[iOS/Swift] Model 안의 멤버변수로 배열 정렬하기

U_Daeng 2022. 10. 24. 18:56

영화 검색 api 를 불러왔을 때 있는 별점(userRating)을 기준으로 내림차순 해봤다!

객체 안에 멤버변수로는 title, image, director, actor, userRating이 존재한다.

 self.list = list.sorted(by: {$0.userRating > $1.userRating})

💡 결과

'IOS > Swift' 카테고리의 다른 글

[Swift] zip(_:_:)에 대하여..  (0) 2024.05.22
[Swift] suffix(_:)에 대하여..  (0) 2024.05.17
[Swift] prefix(_:)에 대하여..  (0) 2024.05.17
[Swift] joined(separator:)에 대해..  (0) 2024.05.09
[Swift] 고차함수 map(_:)에 대해..  (0) 2024.05.07