We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 92e797a commit 70fdd27Copy full SHA for 70fdd27
Insertion Sort/InsertionSort.swift
@@ -2,11 +2,11 @@
2
///
3
/// - Parameters:
4
/// - array: the array of elements to be sorted
5
-/// - sortedArray: copy the array to save stability
6
/// - isOrderedBefore: returns true if the elements provided are in the corect order
7
/// - Returns: a sorted array containing the same elements
8
func insertionSort<T>(_ array: [T], _ isOrderedBefore: (T, T) -> Bool) -> [T] {
9
guard array.count > 1 else { return array }
+ /// - sortedArray: copy the array to save stability
10
var sortedArray = array
11
for index in 1..<sortedArray.count {
12
var currentIndex = index
0 commit comments