public class InsertionSort
{
public static void main(String[] args)
{
int[] a = {5,2,4,6,1,3,0};
sort(a);
for(int i = 0; i < a.length; i++)
{
System.out.print(a[i] + " ");
}
}
static void sort(int[] x)
{
int i, j, key;
for(j = 1; j < x.length; j++)
{
key = x[j];
i = j - 1;
while(i >= 0 && x[i] > key)
{
x[i + 1] = x[i--];
}
x[i + 1] = key;
}
}
}