You are viewing a single comment's thread. Return to all comments →
Swift
func insertionSort2(n: Int, arr: [Int]) -> Void { var sortArr: [Int] = arr for i in 1..<sortArr.count { for j in stride(from: i, through: 0, by: -1) { if arr[i] < sortArr[j] { sortArr[j+1] = sortArr[j] sortArr[j] = arr[i] } else { continue } } printer(sortArr) } } func printer(_ arr: [Int]) { print(arr.map({ String($0)}).joined(separator: " ")) }
Insertion Sort - Part 2
You are viewing a single comment's thread. Return to all comments →
Swift