(inout source: C) { for i in indices(source) { for var j=i; j!=source.startIndex && source[j]<source[j-1]; j-- { swap(&source[j-1], &source[j]) } } } This%version:%420µs%!
source: C) { if isEmpty(source) { return } for i in source.startIndex.successor()..<source.endIndex { let x = source[i] var j = i while j != source.startIndex { let k = j.predecessor() let cmp = source[k] if x < cmp { source[j] = cmp j = k } else { break } } source[j] = x } }