/* Beispiel für Sortieren mit Bubblesort
*
* @autor Eduard Heindl
* @date 2008-12-18
* @version 1.0
*
***********************/
import Prog1Tools.IOTools;

public class bubblesort
{
  public static void main(String args[])
  {
      int [] liste = {5,3,8,2,2,1,7,7};
      
      Ausgabe(liste);
      Sortierenf(liste);
      System.out.println("Jetzt ist sortiert mit For!");
      Ausgabe(liste);
        
  }//Class main
      
      public static void Ausgabe(int[] l){
        for(int i=0; i<l.length; i++){
            System.out.print(l[i]);
        }// for
        System.out.println();
    }// Ausgabe
    
      public static void Sortieren(int [] l){
        int i;
        int t;
        for(int j=0; j<l.length; j++){
           i=0; 
           while(i<(l.length-1)){
             if(l[i]<l[i+1])
             {}
             else
             { // Tausch der Werte 
               t=l[i];
               l[i]=l[i+1];
               l[i+1]=t; 
             }
             i++;
           }//while
        }// Äussere Forschleife, damit die Bubbles bis nach oben aufsteigen
    } // Sortieren
    
    
        public static void Sortierenf(int [] l){
        int t;
        for(int j=0; j<l.length; j++){
            for(int i=0;i<(l.length-1);i++)
            { // Tausche falls notwendig
             if(l[i]<l[i+1])
             {}
             else
             { // Tausch der Werte 
               t=l[i];
               l[i]=l[i+1];
               l[i+1]=t; 
             }            
           }//for
           Ausgabe(l);
        }// Äussere Forschleife, damit die Bubbles bis nach oben aufsteigen
    } // Sortierenf

}//Class bubblesort

