Skip to content

Commit

Permalink
Fix keeping category order in root
Browse files Browse the repository at this point in the history
  • Loading branch information
jessevdk committed Aug 14, 2014
1 parent 212d63a commit 6cbdc24
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions cldoc/nodes/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,19 @@ def is_anonymous(self):
return True

def sorted_children(self):
schildren = Node.sorted_children(self)
schildren = list(Node.sorted_children(self))

# Keep categories in order though
c = [x for x in self.children if isinstance(x, Category)]
c.reverse()

if len(c) == 0:
return schildren

start = -1
end = len(schildren)

for i in range(0, len(schildren)):
if start == -1 and isinstance(schildren[i], Category):
start = i
elif start != -1 and not isinstance(schildren[i], Category):
end = i
if isinstance(schildren[i], Category):
schildren[i] = c.pop()

return schildren[:start] + c + schildren[end:]
return schildren

# vi:ts=4:et

0 comments on commit 6cbdc24

Please sign in to comment.