Skip to content

Commit ae44a30

Browse files
authored
Merge pull request kodecocodes#484 from Darr758/patch-1
Create ShellSortExample.swift
2 parents 17bf20d + 1bc6990 commit ae44a30

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Shell Sort/ShellSortExample.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public func shellSort(_ list : inout [Int]) {
2222

2323
guard sublistCount == 1 && index > 0 else { continue }
2424

25-
while list[index - 1] > list[index] && index - 1 > 0 {
25+
while index > 0 && list[index - 1] > list[index] {
2626
swap(&list[index - 1], &list[index])
2727
index -= 1
2828
}

0 commit comments

Comments
 (0)