Category : BASIC Source Code
Archive   : QB_CODE.ZIP
Filename : SSRTSTR.BAS

 
Output of file : SSRTSTR.BAS contained in archive : QB_CODE.ZIP

'
' SSRTSTR.BAS - For the QuickBASIC Toolbox
' Shell Sort Strings Routine
'

'
' $INCLUDE: 'TOOLBOX.BI'
'

DEFINT A-Z

SUB SSORTSTR (ARRAY$(), LEFT, RIGHT)
LENGTH = RIGHT - LEFT + 1
DO
LENGTH = LENGTH \ 2
IF LENGTH < 1 THEN
EXIT SUB
END IF
LOWER = LEFT
UPPER = LOWER + LENGTH
DO
HIGHEST = LOWER
DO WHILE ARRAY$(UPPER) < ARRAY$(LOWER)
SWAP ARRAY$(LOWER), ARRAY$(UPPER)
UPPER = LOWER
LOWER = UPPER - LENGTH
IF LOWER < LEFT THEN
EXIT DO
END IF
LOOP
LOWER = HIGHEST + 1
UPPER = LOWER + LENGTH
LOOP UNTIL UPPER > RIGHT
LOOP
END SUB