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