Skip to content

Commit d705414

Browse files
authored
Update displayed code to use 2 space indentation
1 parent 90730ad commit d705414

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Heap Sort/README.markdown

+9-9
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ Here's how you can implement heap sort in Swift:
4848

4949
```swift
5050
extension Heap {
51-
public mutating func sort() -> [T] {
52-
for i in stride(from: (elements.count - 1), through: 1, by: -1) {
53-
swap(&elements[0], &elements[i])
54-
shiftDown(0, heapSize: i)
55-
}
56-
return elements
51+
public mutating func sort() -> [T] {
52+
for i in stride(from: (elements.count - 1), through: 1, by: -1) {
53+
swap(&elements[0], &elements[i])
54+
shiftDown(0, heapSize: i)
5755
}
56+
return elements
57+
}
5858
}
5959
```
6060

@@ -71,9 +71,9 @@ We can write a handy helper function for that:
7171

7272
```swift
7373
public func heapsort<T>(_ a: [T], _ sort: @escaping (T, T) -> Bool) -> [T] {
74-
let reverseOrder = { i1, i2 in sort(i2, i1) }
75-
var h = Heap(array: a, sort: reverseOrder)
76-
return h.sort()
74+
let reverseOrder = { i1, i2 in sort(i2, i1) }
75+
var h = Heap(array: a, sort: reverseOrder)
76+
return h.sort()
7777
}
7878
```
7979

0 commit comments

Comments
 (0)