/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package insertionsort;
/**
*
* @author Angga
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int[] array={4,6,3,8,2,5,8,9,6};
for(int j=1;j<array.length;j++){
int sementara=array[j];
int i=j-1;
while(i>=0 && array[i]>sementara){
array[i+1]=array[i];
i–;
}
array[i+1]=sementara;
}
for(int i=0;i<array.length;i++){
System.out.print(array[i]+” “);
}
}
}