Sorting an Array

A Bubble-Sort algorithm compares neighbors in an array
and exchanges them if they are out of order.
It must go through the entire array, and then through the
entire array again, and again until finished.  It may take
as many passes as there are numbers in the array.

Write an algorithm to perform a Bubble-Sort on an array of ints.

Solution

public void bubbleSort( int[]  data )
{
    for(int pass = 0pass < data.lengthpass = pass + 1)
    {
        for(int x = 0x < data.length - 1x = x+1)
        {
            if ( data[x] > data[x+1] )
            {
                 int temp = data[x];
                 data[x] = data[x+1];
                 data[x+1] = temp;
            }
        }
    }
}