Sort List Descending

后端 未结 4 1782
无人共我
无人共我 2020-12-13 17:19

In c# (3.0 or 3.5, so we can use lambdas), is there an elegant way of sorting a list of dates in descending order? I know I can do a straight sort and then reverse the whole

4条回答
  •  情深已故
    2020-12-13 17:43

    Though it's untested...

    docs.Sort((x, y) => y.StoredDate.CompareTo(x.StoredDate));
    

    should be the opposite of what you originally had.

提交回复
热议问题