0

I am currently working on a little program for myself, connected to LastFM. Here I can fetch a whole list artists, played in the current week. This is how I first fetch the artists played and store them into a list:

WeeklyArtistChart WeeklyArtists = user.GetWeeklyArtistChart();
//WeeklyArtistChart is a list

Now, let's say each entry in WeeklyArtists[i].Artist has a property named 'Playcount'. I want to sort my list based on that property in descending order, only problem is, I have no idea how!

Your help would be greatly appreciated!

4

1 に答える 1

2

LINQとEnumerable.OrderByDescending:を使用できます

var sortedArtists = WeeklyArtists.OrderByDescending(a => a.Artist.Playcount);

この注文のリストのコピーが必要な場合は、次の電話番号に電話する必要がありますToList

WeeklyArtists = sortedArtists.ToList();
于 2012-06-04T15:14:17.757 に答える