Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//Bubble Sort Algorithm
func bubbleSort(inputData: inout [Int]) {
var inputDataLength = inputData.count
while inputDataLength != 0 {
var newn = 0
for forwardPointer in 1...inputDataLength - 1 {
if (inputData[forwardPointer - 1] > inputData[forwardPointer]) {
let temp = inputData[forwardPointer - 1]
inputData[forwardPointer - 1] = inputData[forwardPointer]
inputData[forwardPointer] = temp
newn = forwardPointer
}
}
inputDataLength = newn
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.