If Category.SubCategories is a collection in itself, you cannot order it using existing extension methods (and c => c.SubCategories as x => x.Order translates into almost nothing, basically saying that SubCategories is Func<SubCategory, bool> )
If you are satisfied that the sorting is done in memory (which should not be a problem, since you still get them from the database if you donโt have thousands of things), you can implement your own IComparer<Category> , which requests the SubCategories each Category to determine whether one Category should be placed above or below another Category in the sort operation.
Your expression will be as follows:
var categories = db.Categories.Include("SubCategories").OrderBy(x => x, new CategorySubCategoryComparer())
source share