sub sort(a(1)) static static gap, i, j, a gap = ubound(a) \ 2 while gap > 0 for i = gap + 1 to ubound(a) for j = i - gap to 1 step -gap if a(j) <= a(j + gap) then j = 0 else a = a(j) a(j) = a(j + gap) a(j + gap) = a end if next j next i gap = gap \ 2 wend end subperforms the Shell sort on a list of numbers. The length of the list need not be passed explicitly to the routine since it can be determined using ubound.
from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber