로딩
요청 처리 중입니다...

[Swift] Array - sorted(), sort()

 [Swift] Array - sorted(), sort()

var arrWillSort = [1,4,2,3] var arrWillBeSorted = [1, 4, 2, 3] arrWillSort.sort() // arrWillSort = [1,2,3,4] arrWillBeSorted.sorted() // arrWillBeSorted = [1,4,2,3] // sorted는 반환형임. var new = arrWillBeSorted.sorted() // arrWillBeSorted = [1,4,2,3], new = [1, 2, 3, 4] Closure sorted() 는 클로저가 가능 sorted(by: ) // < or > 로 가능 sorted{ $0 < $1 } //형식으로 가능, 오름차순 < , 내림차순 > + Sorted 는 어떤 정렬 알고리즘을 사용할 까? var temp = [1,4,2,3] print(temp.sorted { print($0, $1) return $0 > $1 }) /* 4 1 2 1 2 4 3 1 3 2 3 4 [4...