c# - Sort a list by an int property in the list differing per entry -
i working on little program myself, connected lastfm. here can fetch whole list artists, played in current week. how first fetch artists played , store them list:
weeklyartistchart weeklyartists = user.getweeklyartistchart(); //weeklyartistchart list now, let's each entry in weeklyartists[i].artist has property named 'playcount'. want sort list based on property in descending order, problem is, have no idea how!
your appreciated!
you can use linq , enumerable.orderbydescending:
var sortedartists = weeklyartists.orderbydescending(a => a.artist.playcount); if need copy of list order, need call tolist:
weeklyartists = sortedartists.tolist();
Comments
Post a Comment