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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -