rendered paste bodyimport java.util.Arrays;
public class Sorting{
// public int compareTo(Object obj){
// if (this < obj){
// return - 1;
// }
// if (this == obj){
// return 0;
// }
// if (this.compareTo(obj) > obj){
// return 1;
// }
// return this.compareTo(obj);
// }
public void insertSort(Comparable [] cArray){
for (int i = 0; i < cArray.length; i ++){
Comparable objOne = cArray[i];
int j = i - 1;
Comparable objTwo= cArray[j];
while(objOne.compareTo(objTwo) > 0 && j > 0){
cArray[j + 1] = cArray[j];
j --;
if(j >= 0){
objTwo= cArray[j];
}
}
cArray[j + 1] = objOne;
System.out.println(Arrays.toString(cArray));
}
}
}