/*
 * BubbleSort.java
 * Aufgabe 3
 */

/**
 *
 * @author  Christian Weidauer
 */
public class BubbleSort {

   // zu sortierendes Zahlenfeld
    private static int[] test
                          = { 10, 75, 24, 32, 98,
                              72, 88, 43, 60, 35,
                              54, 62,  2, 12, 82 };

    public static void main( String[] args ) {

        sort( test );

        for( int i=0; i<test.length; i++ ) {
            System.out.println( (i+1) + ".: " + test[i] );
        }
    }

    /** Operation, die das übergebene Zahlenfeld mit BubbleSort sortiert. */ 
    public static void sort( int[] array ) {
        int tmp=0; 
        for( int i=0; i<array.length-1; i++ ) {
           for( int j=0; j<array.length-i-1; j++ ) {
              if( array[j] > array[j+1] ) {
                  tmp = array[j];
                  array[j] = array[j+1];
                  array[j+1] = tmp;
              }
           }
        }
    }
}
