Jump to content

Sorting algorithms/Bubble sort: Difference between revisions

Add Seed7 example
(→‎[[Perl]]: syntax highlight)
(Add Seed7 example)
Line 281:
puts [3, 78, 4, 23, 6, 8, 6].bubblesort1!
# => [3, 4, 6, 6, 8, 23, 78]
 
==[[Seed7]]==
[[Category:Seed7]]
const proc: bubblesort (inout array integer: arr) is func
local
var integer: i is 0;
var integer: j is 0;
var integer: help is 0;
begin
for i range 1 to length(arr) do
for j range succ(i) to length(arr) do
if arr[i] < arr[j] then
help := arr[i];
arr[i] := arr[j];
arr[j] := help;
end if;
end for;
end for;
end func;
 
var array integer: arr is [] (3, 78, 4, 23, 6, 8, 6);
 
bubblesort(arr);
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.