C# list.Orderby descending

后端 未结 6 2290
不知归路
不知归路 2020-11-30 22:05

I would like to receive a list sorted by \'Product.Name\' in descending order.

Similar to the function below which sorts the list

6条回答
  •  一个人的身影
    2020-11-30 22:55

    Sure:

    var newList = list.OrderByDescending(x => x.Product.Name).ToList();
    

    Doc: OrderByDescending(IEnumerable, Func).

    In response to your comment:

    var newList = list.OrderByDescending(x => x.Product.Name)
                      .ThenBy(x => x.Product.Price)
                      .ToList();
    

提交回复
热议问题