func insertion_sort(array:Array<Int>) -> Array<Int> {
var array = array
for index in 1..<array.count {
let value = array[index]
var i = index - 1
while i>=0 {
if value < array[i] {
array[i+1] = array[i];
array[i] = value
i = i - 1
}else {
break
}
}
}
return array;
}
网友评论