I have a list of items
- ParentID
- 1 abc 0 (level1)
- 2 def 1
- 3 ghi 1
- 4 jkl 0
- 5 mno 2
- 6 pqr 5
- 7 aaa 1
- 8 vwx 0
I want the list to sort as
ABC, AAA, Protection, MnO, GHI, JKL, VWX,
that is, I want the parent (ascending order of the name), its children (in ascending order of the name), children of the children (ascending order of the child), etc. to the last level, and then again parent. I have
sections = new List<section>( from section in sections group section by section.ParentID into children orderby children.Key from childSection in children.OrderBy(child => child.Name) select childSection);
But sorts the list as abc, jkl, vwx, aaa, def, ghi, mno, pqr
Someone can tell me where I'm wrong.
source share