你如何通过linq中的最大数字订购

use*_*969 5 c# linq

我想按数量顺序打印产品.总产量较大的产品应该是第一位的.

我在这里错过了什么,因为它不按顺序打印或总计打印

class Program
{
    static void Main()
    {
        var products=new List<Product>
                         {
                             new Product {Name = "Apple", Total = 5},
                             new Product {Name = "Pear", Total = 10}
                         };

        var productsByGreatestQuantity = products.OrderBy(x => x.Total);

        foreach (var product in productsByGreatestQuantity)
        {
            System.Console.WriteLine(product.Name);
        }
        System.Console.Read();
    }
}

public class Product
{
    public string Name { get; set; }
    public int Total { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

Roy*_*tus 8

var data = products.OrderByDescending(x => x.Total);
Run Code Online (Sandbox Code Playgroud)