initiate counter (j)
while j is less than length(A) -
/* if this pair is out of order */
if A[index-1] > A[index] then
/* swap them and remember something changed */
swap( A[index-1], A[index] )
swapped = true
end if
end while
increment counter (j)
p.s your brackets are not matching are you missing a code segment?