package InsertionSort;
public class InsertionSort {
public static void main(String a[]){
int i;
String array[] = {"I","N","S","E","R","T","I","O","N"};
System.out.println("Before sort:\n");
for(i = 0; i < array.length; i++){
System.out.print( array[i]+" "); }
System.out.println();
insertion_srt(array, array.length);
System.out.print("After sort:\n");
for(i = 0; i <array.length; i++){
System.out.print(array[i]+" ");
System.out.println();}
}
public static void insertion_srt(String array[], int z){
for (int i = 1; i < z; i++){
int j = i;
String B = array[i];
while ((j > 0) && (array[j-1] > B)){
array[j] = array[j-1];
j--;
}
array[j] = B;
}
}