Sorting algorithms/Bubble sort: Difference between revisions

Section moved
(Section moved)
Line 3,328:
<lang scheme>(bsort > '(2 4 6 2))
(1 2 3)</lang>
 
=={{header|Scilab}}==
<lang>function b=BubbleSort(a)
n=length(a)
swapped=%T
while swapped
swapped=%F
for i=1:1:n-1
if a(i)>a(i+1) then
temp=a(i)
a(i)=a(i+1)
a(i+1)=temp
swapped=%T
end
end
end
b=a
endfunction BubbleSort</lang>
{{out}}
<pre style="height:20ex">-->y=[5 4 3 2 1]
y =
5. 4. 3. 2. 1.
-->x=BubbleSort(a)
x =
1. 2. 3. 4. 5. </pre>
 
=={{header|Seed7}}==
1,392

edits