Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,22 @@
func gnomeSort<T: Comparable>(_ a: inout [T]) {
var i = 1
var j = 2
while i < a.count {
if a[i - 1] <= a[i] {
i = j
j += 1
} else {
a.swapAt(i - 1, i)
i -= 1
if i == 0 {
i = j
j += 1
}
}
}
}
var array = [10, 8, 4, 3, 1, 9, 0, 2, 7, 5, 6]
print("before: \(array)")
gnomeSort(&array)
print(" after: \(array)")