public void insertion () { int i, j; int itemToInsert; for (i = 1; i < list.length; i++) { if (list[i] < list[i-1]) { itemToInsert = list[i]; j = i - 1; while (j >= 0) { list[j+1] = list[j]; if ((j == 0) || (list[j-1] <= itemToInsert)) break; else j--; } // Inner while loop list[j] = itemToInsert; } // if condition (elements out of order) } // end of outer for loop } // end of method