I have the insertionSort method done. I am certain that it is proper. However, When I am trying to test it, I don't know what to pass in for the comparator argument. Please refer to the code below.
public static <T> void insertionSort(T[] a, Comparator <? super T> c)
{
for (int i = 1; i< a.length; i++)
{
T val = a[i];
int j;
for (j = i-1; j>=0; j-- )
{
if (c.compare(a[j], val) <= 0) break;
a[j+1] = a[j];
}
a[j+1] = val;
}
}
//for testing
int[] num = {15, 3, 2, 9, 12, 83, 0};
AnagramUtil.insertionSort(num, c);//c is the comparator