Skip to content

Commit 04faa7a

Browse files
authored
Merge pull request #1 from JulioBBL/bubble-fix
improves Bubble sort documentation
2 parents 2fdd8b8 + 9577f40 commit 04faa7a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Bubble Sort/MyPlayground.playground/Sources/BubbleSort.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ import Foundation
2323

2424
/// Performs the bubble sort algorithm in the array
2525
///
26-
/// - Parameter elements: a array of elements that implement the Comparable protocol
26+
/// - Parameter elements: Array of Comparable elements to be sorted
2727
/// - Returns: an array with the same elements but in order
2828
public func bubbleSort<T> (_ elements: [T]) -> [T] where T: Comparable {
2929
return bubbleSort(elements, <)
3030
}
3131

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
3237
public func bubbleSort<T> (_ elements: [T], _ comparison: (T,T) -> Bool) -> [T] {
3338
var array = elements
3439

0 commit comments

Comments
 (0)