File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Bubble Sort/MyPlayground.playground/Sources Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,17 @@ import Foundation
23
23
24
24
/// Performs the bubble sort algorithm in the array
25
25
///
26
- /// - Parameter elements: a array of elements that implement the Comparable protocol
26
+ /// - Parameter elements: Array of Comparable elements to be sorted
27
27
/// - Returns: an array with the same elements but in order
28
28
public func bubbleSort< T> ( _ elements: [ T ] ) -> [ T ] where T: Comparable {
29
29
return bubbleSort ( elements, < )
30
30
}
31
31
32
+ /// Performs the bubble sort algorithm in the array
33
+ /// - Parameters:
34
+ /// - elements: Array of Comparable elements to be sorted
35
+ /// - comparison: The method that will tell the algorithm if two elements are ordered
36
+ /// - Returns: an array with the same elements but in order
32
37
public func bubbleSort< T> ( _ elements: [ T ] , _ comparison: ( T , T ) -> Bool ) -> [ T ] {
33
38
var array = elements
34
39
You can’t perform that action at this time.
0 commit comments