//泛型数组 冒泡排序
        static T[] sort<T>(T[] x) where T:IComparable<T>
        {
            T b = default(T);
            for (int i = 0; i < x.Length-1; i++)
            {
                for (int j = 0; j < x.Length-i-1; j++)
                {
                    if (x[j].CompareTo(x[j+1])<0)
                    {
                        b = x[j];
                        x[j] = x[j + 1];
                        x[j + 1] = b;
                    }
                }
            }
            return x;
        }
posted on 2019-11-04 16:48  .net之路  阅读(46)  评论(0编辑  收藏  举报