list排序 根据 数字大小排序     目前 1,2,3,4,100    排序出来的是1,100,2,3,4  我要的是100,4,3,2,1
怎么排序啊???  

解决方案 »

  1.   


    list = list.OrderByDescending(s => s).ToList();
      

  2.   

    tempDS = tempDS.OrderBy(od1 => od1.Value).ToList();
      

  3.   


                List<string> list = new List<string>();
                list.Add("1");
                list.Add("2");
                list.Add("3");
                list.Add("4");
                list.Add("100");
                var vs = list.OrderByDescending(x=>Convert.ToInt32(x));
      

  4.   

    staticvoid Main(string[] args)
    {
        List<orderData> temp =new List<orderData>(new orderData[] { 
            new orderData() { Label ="a", Value =5, SId =1 }, 
            new orderData() { Label ="c", Value =1, SId =2 }, 
            new orderData() { Label ="b", Value =7, SId =3 } });
        temp = temp.OrderBy(t => t.Value).ToList();
        temp.ForEach(t => Console.WriteLine("SID : "+ t.SId.ToString() +", Label : "+ t.Label +", Value : "+ t.Value.ToString()));
        Console.ReadKey();
    }class orderData
    {
        publiclong? SId { get; set; }
        publicstring Label { get; set; }
        publicdouble? Value { get; set; }
    }