I want to share my simple solution.
I had similiar problem. Thanks for all suggestions. But I like simple solutions.
What is my problem? I have a list like category systems. Some categories are upper categories and some of them are lower categories. I need list them all on the same time in the correct order.
Something like this.
1. Category 1
2. Category 2
2.1 Sub Category 1
2.2 Sub Category 2
3. Category 3
I have a nullable int field UpperCategoryId and non-nullable int Order field and text field.
When I list categories, I calculate a double number like this
DoubleOrder = Convert.ToDouble(x.UpperCategoryId.HasValue ? x.UpperCategory.Order + (x.Order/10.0) : 0 + x.Order)
This takes UpperCategories orders same. Takes subcategories values as decimal. Then I order by DoubleOrder
.OrderBy(x => x.DoubleOrder)
And my result is exactly what I want.