public static void sort(IComparable[] a)
{
int N = a.Length;
for (int i = 0; i < N; i++)
{
for (int j = i; j > 0 && less(a[j], a[j - 1]); j--)
{
exch(a, j, j - 1);
}
isSorted(a, 0, i);
}
isSorted(a);
}
Above is simple sorting code I found in book, the code is wrote in java and I try to translate it in c#.
Everything is fine, except how to pass the parameter.
Int32 is implement the icamparable
, but how can I create a instance of IComparable[]
and pass to the sorting function.
IComparable[] b = new int[] { 2, 3, 3, 3, 3, 3, 3, 3 };
Does NOT work.