Secondary ordering in NewsList

Vote:
 
Is there a way to order  by a second field, ie I have lots of news items sorted by published date, for each date I want all the news to be alphabetical.?
#20084
May 20, 2008 14:08
Vote:
 

This is how i solved it, might be an easier way to do it.

pdcNews.Sort(new Util.JobComparer());
somenewslist.DataSource = pdcNews;
somenewslist.DataBind();

 

public class JobComparer : IComparer
{

public int Compare(PageData pd1, PageData pd2)
{
if (pd1.StartPublish < pd2.StartPublish)
return 1;
else if (pd1.StartPublish > pd2.StartPublish)
return -1;

return pd1.PageName.CompareTo(pd2.PageName);
}
}
#20085
May 20, 2008 14:22
Vote:
 

Thanks for the reply, does that sort on a secondary field though? I have a drop down which allows the user to sort on 4 differant properties with the added ability to do it ascending or decending.

Once it is sorted on any of those fields it then needs to be sub-ordered alphabetically.  so all the news for thurs would be in alphabetical, then all news for fri would be in alphabetical?

#20086
May 20, 2008 15:12
Vote:
 

Well, this sorts first by Startpublish, then PageName, in your case you have to modify it pretty heavily.

you can allways try this out, might work..

new EPiServer.Filters.FilterPropertySort("PageName").Filter(pdcNews);
new EPiServer.Filters.FilterPropertySort(propertyname, (isASC ? FilterSortDirection.Ascending : FilterSortDirection.Descending)).Filter(pdcNews);
#20087
Edited, May 20, 2008 15:26