Successful solution to 7.1.

This commit is contained in:
Anna Rose Wiggins 2018-12-10 00:29:13 -05:00
parent f6ea56d266
commit 7f0bc4d9f1
No known key found for this signature in database
GPG key ID: 8D9ACA841015C59A
2 changed files with 36 additions and 42 deletions

View file

@ -39,16 +39,15 @@ func BuildDependencyTree(data []string) *Node {
// sort the children in each node
for _, node := range depMap {
sortChildren(node)
sortNodes(node.Children)
}
return BuildTreeRoot(depMap)
}
func sortChildren(node *Node) {
children := node.Children
sort.Slice(children[:], func(i, j int) bool {
return children[i].Name < children[j].Name
func sortNodes(nodes []*Node) {
sort.Slice(nodes[:], func(i, j int) bool {
return nodes[i].Name < nodes[j].Name
})
}
@ -62,6 +61,6 @@ func BuildTreeRoot(depMap map[rune]*Node) *Node {
}
}
sortChildren(root)
sortNodes(root.Children)
return root
}