traverse the array from 0 to n - i - 1. Swap if the element found is greater than the next element
$ t = $ arr [ $ j ] ; $ arr [ $ j ] = $ arr [ $ j + 1 ] ; $ arr [ $ j + 1 ] = $ t ; $ swapped = True ; } }