
public class InsertSortAlgorithm extends SortAlgorithm {
  public InsertSortAlgorithm(AlgorithmAnimator animator) {
    super(animator);
  }

  protected void ISort(int a[], int i) {
	  int temp;
	  temp = a[i];
	  int j= i-1;
	  while ((j >= 0) && (a[j]>temp)){
		  a[j+1] = a[j];
		  j = j - 1;
		  pause();
      }
      a[j+1] = temp;
  }

  public void sort(int a[]) {
	  for (int i=1; i < a.length; i++){
              ISort(a, i);
	  }
  }
}

