C# sort tuple by descending
C# order by descending
LINQ is your friend.
Assume we have tuple book {name, path, category, count}
foreach (var b in books.OrderByDescending(key => key.count))
{
o.WriteLine(string.Format("{0},{1},{2},{3}", b.name, b.path, b.count, b.category));
}
Although I don't work for Microsoft any more (and probably won't in the future), still I have to admit LINQ is good if it's not performance critical.
No comments:
Post a Comment