array 为Control数组,
Array.Sort(array, 0, array.Length,IComparer);
IComparer要怎样写?谢谢

解决方案 »

  1.   


            public class IntComparer : IComparer<int>
            {
                public int Compare(int x, int y)
                {
                    return y-x;
                }
            }
            class Program
            {
                static void Main(string[] args)
                {
                    int[] arr = { -32, -10, 33, -23, 32, -12, 41, -12, 12 };
                    Array.Sort(arr, new IntComparer());
                    foreach (int i in arr)
                        Console.WriteLine(i);
                    Console.ReadLine();
                }
    }
      

  2.   

    array = array.OrderBy(x => x.属性).ToArray();