Skip to content
Snippets Groups Projects
Commit fd41b55f authored by legac's avatar legac
Browse files

Add a method to sort children according to alphabetical order.

parent d7ea70e6
No related branches found
No related tags found
No related merge requests found
......@@ -159,3 +159,19 @@ class Node(object):
"""
return {'text': self.text, 'children': self.children}
def sort_children(self):
"""sort children according to alphabetical order.
"""
di = {}
for child in self.children:
di[child['text']] = child
names = di.keys()
names.sort(cmp=locale.strcoll)
self.children = []
for name in names:
self.children.append(di[name])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment