Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds documentation for Bubble Sort #953

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion Bubble Sort/MyPlayground.playground/Sources/BubbleSort.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ import Foundation

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

/// Performs the bubble sort algorithm in the array
/// - Parameters:
/// - elements: Array of Comparable elements to be sorted
/// - comparison: The method that will tell the algorithm if two elements are ordered
/// - Returns: an array with the same elements but in order
public func bubbleSort<T> (_ elements: [T], _ comparison: (T,T) -> Bool) -> [T] {
var array = elements

Expand Down