Sorting algorithms/Bubble sort: Difference between revisions

Line 5,377:
// ...
bubble_sort(list);</syntaxhighlight>
 
=={{header|Pebble}}==
<syntaxhighlight lang="pebble">;bubble sort example for x86 DOS
;compiles to 549 bytes com file
 
program examples\bubble
 
data
 
int sorting[0]
int index[0]
int size[10]
int temp1[0]
int temp2[0]
 
int@ list[10]
 
begin
 
call fill
call sort
call output
 
pause
kill
 
end
 
sub fill
 
0 [index]
 
label loopfill
 
echo "Enter value #" \
echo [index]
echo ": " \
 
input @list{[index]}
 
+1 [index]
 
if [index] < [size] then loopfill
 
ret
 
sub sort
 
label loopsort
 
0 [sorting]
 
0 [index]
 
label process
 
[temp1] = [index] + 1
 
if @list{[index]} > @list{[temp1]} then
 
[temp2] = @list{[index]}
 
@list{[index]} = @list{[temp1]}
@list{[temp1]} = [temp2]
 
[sorting] = 1
 
endif
 
+1 [index]
 
if [index] < [size] - 1 then process
 
if [sorting] = 1 then loopsort
 
ret
 
sub output
 
0 [index]
 
label loopoutput
 
echo [index]
echo " : " \
echo @list{[index]}
crlf
 
+1 [index]
 
if [index] < [size] then loopoutput
 
ret</syntaxhighlight>
 
=={{header|Perl}}==
305

edits