views:

87

answers:

1

Hi,

I have a function in sitefinity that returns a list of categories.

//return list of categories
    private IList<ICategory> GetCategoryDataSource() {

        var cntManager = new ContentManager(CaseStudyManager.DefaultContentProvider);
        IList allCategories = cntManager.GetCategories();
        List<ICategory> filteredList = new List<ICategory>();
        foreach (ICategory category in allCategories) {

            filteredList.Add(category);

        }
        return filteredList;
    }

What I want to know is how to sort this list.

Categories in Sitefinity are as far as i can tell just a string, there are no other fields associated with a category. Therefore I have nothing to sort the categories on, other than appending each category with a number, like:

1 - Legal
2 - Financial
3 - Property

When these categories are displayed on the website I can then at least trim the parts i need.

Can anyone help with the sorting though?

Thanks Al

A: 

Use IComparer Interface

Bolu