Sorting algorithms/Bubble sort: Difference between revisions
Content deleted Content added
Nimrod -> Nim |
add swift |
||
Line 3,692: | Line 3,692: | ||
x::(bubble (y::rest)) |
x::(bubble (y::rest)) |
||
</pre> |
</pre> |
||
=={{header|Swift}}== |
|||
<lang Swift>func bubbleSort<T:Comparable>(inout list:[T]) { |
|||
var done = false |
|||
while !done { |
|||
done = true |
|||
for i in 1..<list.count { |
|||
if list[i - 1] > list[i] { |
|||
(list[i], list[i - 1]) = (list[i - 1], list[i]) |
|||
done = false |
|||
} |
|||
} |
|||
} |
|||
}</lang> |
|||
=={{header|TI-83 BASIC}}== |
=={{header|TI-83 BASIC}}== |