REM This QuickSort routine was given to me by John Davies - and he asked for me to distribute it around newsgroups. It's for OPL32 - enjoy: PROC Main: LOCAL Generation(100), i% REM Fill up Generation() with some numbers for the demo i%=1 DO Generation(i%)=INT(RND*1000) i%=i%+1 UNTIL i%>100 Show:(ADDR(Generation(1)),100) PRINT QSort:(ADDR(Generation(1)),0,99) Show:(ADDR(Generation(1)),100) GET ENDP PROC Show:(PArray&,size%) LOCAL i% i%=0 DO PRINT PEEKF(PArray&+i%*8), i%=i%+1 UNTIL i%>=size% ENDP PROC QSort:(PArray&,lo0%,hi0%) LOCAL lo%,hi%,mid lo%=lo0% : hi%=hi0% IF hi0%>lo0% mid=PEEKF(PArray&+((lo0%+hi0%)/2*8)) WHILE lo%<=hi% WHILE lo%lo0% AND PEEKF(PArray&+hi%*8)>mid hi%=hi%-1 ENDWH IF lo%<=hi% Swap:(PArray&,lo%,hi%) lo%=lo%+1 hi%=hi%-1 ENDIF ENDWH IF lo0%