文章内容

2017/3/7 14:28:39,作 者: 黄兵

.OrderByDescending排序

利用扩展方法OrderByDescending对数组进行降序排序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = { 1, 2, 3, 4, 83, 12, 232, 24, 67, 122, 12 };
            int[] b = a.OrderByDescending(x => x).ToArray();
            forint i=0; i<b.Length;i++)
            {
                Console.Write("{0} ", b[i]);
            }
        }
    }
}

最后显示效果如下:

Enumerable.OrderByDescending 方法 :按降序对序列的元素排序,排序的依据是方法参数里的lambda表达式的值

分享到:

发表评论

评论列表