Option Base 0 Dim xx As Integer xx=my_arraysize 'lack of UBOUND() means we have to manually track the array size Dim SP$(xx) ShellSort xx
SUB ShellSort(SPTop) LOCAL INTEGER i,j LOCAL FLOAT k LOCAL STRING a$ k = INT(SPTop / 2) WHILE k > 0 FOR i = 1 to SPTop j = i a$ = SP$(i) WHILE (j >= k+1 AND SP$(ABS(j-k)) > a$) SP$(j) = SP$(j-k) j = j - k WEND sp$(j) = a$ NEXT IF k = 2 THEN k = 1 ELSE k = INT(k * 0.454545) ' 5/11 sort balancing value END IF WEND END SUB