zoukankan      html  css  js  c++  java
  • c#比较器 排序

    原地址:http://blog.csdn.net/xutao_ustc/article/details/6314057

    class Program
        {
            static void Main(string[] args)
            {
                Data[] array = new Data[] { new Data() { a = 1 }, new Data() { a = 3 }, new Data() { a = 2 } };
                Array.Sort(array,new MyComparer());
                foreach (var item in array)
                {
                    Console.WriteLine(item.a);
                }
                Console.ReadKey();
            }
        }
        class Data
        {
            public int a{get;set;}
        }
        class MyComparer : IComparer {
            #region IComparer Members
            public int Compare(object x, object y)
            {
                Data a = x as Data;
                Data b = y as Data;
                if (a.a > b.a)
                    return 1;
                else if (a.a == b.a)
                    return 0;
                else
                    return -1;
            }
            #endregion
        }
  • 相关阅读:
    js5
    js4
    js(3)
    JS内容(2)
    html复习
    js介绍及内容(1)
    定位2
    position定位
    CSS
    列表及行块转变
  • 原文地址:https://www.cnblogs.com/123ing/p/3918675.html
Copyright © 2011-2022 走看看