Skip to content

Commit 69cb42e

Browse files
authored
Update ShellSortExample.swift
let code to suit style guide
1 parent 8202cf1 commit 69cb42e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Shell Sort/ShellSortExample.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88

99
import Foundation
1010

11-
public func shellSort(_ list : inout [Int])
12-
{
13-
var sublistCount = list.count / 2
11+
public func shellSort(_ list: inout [Int]) {
1412

15-
while sublistCount > 0
16-
{
17-
for index in 0..<list.count{
18-
13+
var sublistCount = list.count / 2
14+
15+
while sublistCount > 0 {
16+
17+
for index in 0..<list.count {
18+
1919
guard index + sublistCount < list.count else { break }
2020

21-
if list[index] > list[index + sublistCount]{
21+
if list[index] > list[index + sublistCount] {
2222
swap(&list[index], &list[index + sublistCount])
2323
}
2424

2525
guard sublistCount == 1 && index > 0 else { continue }
2626

27-
if list[index - 1] > list[index]{
27+
if list[index - 1] > list[index] {
2828
swap(&list[index - 1], &list[index])
2929
}
3030
}

0 commit comments

Comments
 (0)