Sorting algorithms/Cocktail sort: Difference between revisions
Content added Content deleted
Line 2,397: | Line 2,397: | ||
if swapped then |
if swapped then |
||
swapped~ |
swapped~ |
||
for i=lenA2 to 0 |
for i=lenA2 to 0 |
||
if a(i) > a(i+1) then swap a(i), a(i+1): swapped = true |
if a(i) > a(i+1) then swap a(i), a(i+1): swapped = true |
||
next |
next |
||
end if |
end if |
||
until not swapped |
until not swapped |
||
Line 2,415: | Line 2,415: | ||
if swapped then |
if swapped then |
||
swapped~ |
swapped~ |
||
for i=lenA2 to 0 |
for i=lenA2 to 0 |
||
if a$(i) > a$(i+1) then |
if a$(i) > a$(i+1) then |
||
swap a$(i), a$(i+1) |
swap a$(i), a$(i+1) |
||
swapped = true |
swapped = true |
||
end if |
end if |
||
next |
next |
||
end if |
end if |
||
until not swapped |
until not swapped |