C#里的list泛型的sort排序使用的是数据结构里的哪种排序?
privatestaticintCompare(inti1,inti2){if(i1>i2)return1;if(i1<i2)return-1;return0;}publ...
private static int Compare(int i1, int i2)
{
if (i1 > i2) return 1;
if (i1 < i2) return -1;
return 0;
}
public static List<int> list;
static void Main()
{
int[] a = new int[] {3,5,6,4,2};
list = new List<int>();
foreach (int i in a)
{
list.Add(i);
}
list.Sort(Compare);
foreach (int i in list)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
如这里的Compare();好像是堆排序?????? 展开
{
if (i1 > i2) return 1;
if (i1 < i2) return -1;
return 0;
}
public static List<int> list;
static void Main()
{
int[] a = new int[] {3,5,6,4,2};
list = new List<int>();
foreach (int i in a)
{
list.Add(i);
}
list.Sort(Compare);
foreach (int i in list)
{
Console.WriteLine(i);
}
Console.ReadLine();
}
如这里的Compare();好像是堆排序?????? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询