110,538
社区成员
发帖
与我相关
我的任务
分享
protected void SortInDescendingOrder<T>(ref T[] array)
{
for (int i = 1; i < array.Length; ++i)
{
T temp = array[i];
int j = i;
while ((j > 0) && (array[j - 1] < temp))
{
array[j] = array[j - 1];
--j;
}
array[j] = temp;
}
}
protected void SortInDescendingOrder<T>(ref T[] array) where T : IComparable
{
for (int i = 1; i < array.Length; ++i)
{
T temp = array[i];
int j = i;
while ((j > 0) && (array[j - 1].CompareTo(temp) < 0))
{
array[j] = array[j - 1];
--j;
}
array[j] = temp;
}
}