C# list.Orderby descending

后端 未结 6 2282
不知归路
不知归路 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:28

    look it this piece of code from my project

    I'm trying to re-order the list based on a property inside my model,

     allEmployees = new List(allEmployees.OrderByDescending(employee => employee.Name));
    

    but I faced a problem when a small and capital letters exist, so to solve it, I used the string comparer.

    allEmployees.OrderBy(employee => employee.Name,StringComparer.CurrentCultureIgnoreCase)
    

提交回复
热议问题