How to order a list

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;
    }

I want to know how to sort this list.

Categories in Sitefinity - as far as I can just specify a string, there are no other fields related to the category. Therefore, I have nothing to sort by category other than adding each category with a number, for example:

1 - Legal
2 - Financial
3 - Property

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

Can anyone help with sorting?

Thanks al

+3
source share
2 answers
+1
source

, , , :

001 |

002 | djskdjskd

003 | sdkdsajdaks

foreach (ICategory category in allCategories) 
{              
    filteredList.Add(category.SubString(4);          
} 
0

Source: https://habr.com/ru/post/1771534/


All Articles