Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
fn cocktailSort arr =
|
||||
(
|
||||
local swapped = true
|
||||
while swapped do
|
||||
(
|
||||
swapped = false
|
||||
for i in 1 to (arr.count-1) do
|
||||
(
|
||||
if arr[i] > arr[i+1] then
|
||||
(
|
||||
swap arr[i] arr[i+1]
|
||||
swapped = true
|
||||
)
|
||||
)
|
||||
if not swapped then exit
|
||||
for i in (arr.count-1) to 1 by -1 do
|
||||
(
|
||||
if arr[i] > arr[i+1] then
|
||||
(
|
||||
swap arr[i] arr[i+1]
|
||||
swapped = true
|
||||
)
|
||||
)
|
||||
)
|
||||
return arr
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue