Sorting algorithms/Cocktail sort with shifting bounds: Difference between revisions

m
Swift - use camel case
(Added Swift solution)
m (Swift - use camel case)
Line 833:
=={{header|Swift}}==
{{trans|Rust}}
<lang swift>func cocktail_shaker_sortcocktailShakerSort<T: Comparable>(_ a: inout [T]) {
var begin = 0
var end = a.count
Line 866:
var array = [5, 1, -6, 12, 3, 13, 2, 4, 0, 15]
print("before: \(array)")
cocktail_shaker_sortcocktailShakerSort(&array)
print(" after: \(array)")
 
var array2 = ["one", "two", "three", "four", "five", "six", "seven", "eight"]
print("before: \(array2)")
cocktail_shaker_sortcocktailShakerSort(&array2)
print(" after: \(array2)")</lang>
 
1,777

edits