#COMPILE EXE "s97_bubble_sort.exe"
' Sample: Bubble sort implementation
FUNCTION PBMAIN() AS LONG
    DIM arr(8) AS LONG, i AS LONG, j AS LONG, tmp AS LONG
    arr(0)=64:arr(1)=34:arr(2)=25:arr(3)=12
    arr(4)=22:arr(5)=11:arr(6)=90:arr(7)=45:arr(8)=5
    PRINT "Before:";
    FOR i = 0 TO 8
        PRINT arr(i);
    NEXT i
    PRINT
    FOR i = 0 TO 7
        FOR j = 0 TO 7 - i
            IF arr(j) > arr(j + 1) THEN
                tmp = arr(j)
                arr(j) = arr(j + 1)
                arr(j + 1) = tmp
            END IF
        NEXT j
    NEXT i
    PRINT "After: ";
    FOR i = 0 TO 8
        PRINT arr(i);
    NEXT i
    PRINT
    FUNCTION = 0
END FUNCTION
