Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
m
→{{header|REXX}}: changed some comments and added whitespace.
PatGarrett (talk | contribs) |
m (→{{header|REXX}}: changed some comments and added whitespace.) |
||
Line 3,070:
=={{header|REXX}}==
<lang rexx>/*REXX program sorts an array using the bubble-sort
call gen@ /*generate the array elements. */
call show@ 'before sort' /*show the before array elements.*/
Line 3,078 ⟶ 3,077:
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────BUBBLESORT subroutine───────────────*/
bubbleSort: procedure expose @.; parse arg n /*N:
/*diminish # items each time. */
do until done
done=1 /*assume it's done (1
do j=1 for n-1
k=j+1 /*point to the next item. */
if @.j>@.k then do /*is it out of order
_=@.j /*assign to a temp variable. */
@.j=@.k /*swap current with next. */
@.k=_ /*
done=0 /*indicate it's not done
end /* 1=true 0=false
end /*j*/
end /*until done*/
return
/*──────────────────────────────────GEN@ subroutine─────────────────────*/
gen@: @.= /*assign
@.1 ='---letters of the Hebrew alphabet---' ; @.13='kaph [kaf]'
@.2 ='====================================' ; @.14='lamed'
Line 3,108 ⟶ 3,107:
@.12='yod' ; @.24='taw [tav]'
do highItem=1 while @.highItem\==''
end /*highitem*/
highItem=highItem-1 /*adjust
return
/*──────────────────────────────────SHOW@ subroutine────────────────────*/
show@: widthH=length(highItem) /*maximum width of any line. */
do j=1 for highItem
say 'element' right(j,widthH) arg(1)':' @.j
end /*j*/
say copies('
return</lang>
'''output'''
|