How to sort Generic List Asc or Desc?

后端 未结 2 415
情话喂你
情话喂你 2021-02-01 19:09

I have a generic collection of type MyImageClass, and MyImageClass has an boolean property \"IsProfile\". I want to sort this generic list which IsProfile == true stands at the

2条回答
  •  天涯浪人
    2021-02-01 19:32

    How about:

    estate.Images.OrderByDescending(est => est.IsProfile).ToList()
    

    This will order the Images in descending order by the IsProfile Property and then create a new List from the result.

提交回复
热议问题