London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Sorting blogcollections

Vote:
0

Hi

Is it possible to sort a BlogCollection by property, like you can sort a PageDataCollection with FilterPropertySort? I'm trying to find a nice way to sort blogs by their name.

/Peter

#55841
Dec 20, 2011 10:13
Vote:
0

I think Linq is your friend:

 
// Easy to sort using Linq
var blogs = MethodThatGetsBlogCollection();
var sortedBlogs = blogs.OrderBy(b => b.Header);

// If you cant use the IEnumerable sortedBlogs but need a BlogCollection, you have to loop...:
var sortedBlogCollection = new BlogCollection();
foreach (var blog in sortedBlogs)
{
sortedBlogCollection.Add(blog);
}

 

#55843
Dec 20, 2011 10:49
Vote:
0

The Linq-expression did the trick. I have to study linq more, seems that it solves alot of problems. Thanks!

/Peter

#55846
Dec 20, 2011 11:45
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.