here is the steps using this algorithm to sort:
a)5,2,6,4,1,3
b)2,5,6,4,1,3
c)2,5,6,4,1,3
d)2,4,5,6,1,3
e)1,2,3,4,5,6
int[] a1 = new int[] {5,2,6,4,1,3}; int key; int i; for (int j = 1; j < a1.Length; j++) { key = a1[j]; i = j - 1; while ((i <= 0) && (a1[i] < key)) { a1[i + 1] = a1[i]; i = i - 1; } a1[i+1] = key; }