This is a Bubble-Sortroutine
Captured from a messagein a public Internet news group (see Internet
- Newsgroups)
/* ------------------------------------------------------------------ */
/* function: bubble sort routine */
/* */
/* call: BubbleSort */
/* */
/* returns: nothing */
/* */
/* notes: You must save the elements to sort in the stem "STEM." */
/* stem.0 must contain the number of elements in the stem. */
/* */
/* */
BubbleSort: PROCEDURE expose stem.
do i = stem.0 to 1 by -1 until flip_flop = 1
flip_flop = 1
do j = 2 to i
m = j - 1
if stem.m >> stem.j then /* v2.80 */
do
xchg = stem.m
stem.m = stem.j
stem.j = xchg
flip_flop = 0
end /* if stem.m ... */
end /* do j = 2 ... */
end /* do i = stem.0 ... */
return