Wednesday, July 28, 2010

insertion sort

for pos = 0 to UBound(A)
    val = A(pos)
    for j = pos - 1 to 0 Step -1
        if val < A(j) then
            A(j+1) = A(j)
        else
            exit for
        endif
    next j
    A(j+1) = val
next pos

No comments:

Post a Comment