How to Sort a List<> by a Integer stored in the struct my List<> holds

前端 未结 5 1147
死守一世寂寞
死守一世寂寞 2021-02-04 02:11

I need to sort a highscore file for my game I\'ve written.

Each highscore has a Name, Score and Date variable. I store each one in a List.

Here is the struct tha

5条回答
  •  醉梦人生
    2021-02-04 02:36

    This will sort the list with the highest scores first:

    IEnumerable scores = GetSomeScores().OrderByDescending(hs => hs.Score);
    

提交回复
热议问题