我正在尝试按特定顺序对对象列表进行排序。
Dim myList as new List(Of myObj)
myObj
有 2 个参数Name
(string) 和ParentName
(string)
假设myList
有 n 个项目,它们按以下顺序排列:
myList(0): Name="MD" , ParentName = ""
myList(1): Name="Operations Manager" , ParentName = "MD"
myList(2): Name="Section Sub Manager" , ParentName = "Section Manager"
myList(3): Name="Assistant Manager1" , ParentName = "Tactical Manager"
myList(4): Name="Tactical Manager" , ParentName = "MD"
myList(5): Name="Assistant Manager2" , ParentName = "Tactical Manager"
myList(6): Name="Section Manager" , ParentName = "MD"
我必须对上面的内容进行排序,以便子节点出现在它的父节点之后,即:
myList(0): Name="MD" , ParentName = ""
myList(1): Name="Operations Manager" , ParentName = "MD"
myList(2): Name="Section Manager" , ParentName = "MD"
myList(3): Name="Section Sub Manager" , ParentName = "Section Manager"
myList(4): Name="Tactical Manager" , ParentName = "MD"
myList(5): Name="Assistant Manager1" , ParentName = "Tactical Manager"
myList(6): Name="Assistant Manager2" , ParentName = "Tactical Manager"
请帮忙。