Skip to content

Commit d078c50

Browse files
committed
addition of function description
1 parent 44711ad commit d078c50

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Selection Sort/SelectionSort.playground/Sources/SelectionSort.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/// Performs the Selection sort algorithm on a array
2+
///
3+
/// - Parameter array: array of elements that conform to the Comparable protocol
4+
/// - Returns: an array in ascending order
15
public func selectionSort<T: Comparable>(_ array: [T]) -> [T] {
26
guard array.count > 1 else { return array }
37

@@ -20,6 +24,12 @@ public func selectionSort<T: Comparable>(_ array: [T]) -> [T] {
2024
return a
2125
}
2226

27+
/// Performs the Selection sort algorithm on a array using the provided comparisson method
28+
///
29+
/// - Parameters:
30+
/// - array: array of elements that conform to the Comparable protocol
31+
/// - isLowerThan: returns true if the two provided elements are in the correct order
32+
/// - Returns: a sorted array
2333
public func selectionSort<T>(_ array: [T], _ isLowerThan: (T, T) -> Bool) -> [T] {
2434
guard array.count > 1 else { return array }
2535

0 commit comments

Comments
 (0)