From 486baac69cae47a2a3c115489492033e9a38e6c6 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 10 Aug 2018 12:18:49 +0100 Subject: [PATCH] sort children --- ontology/update.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ontology/update.py b/ontology/update.py index de51c31..c4dfb43 100755 --- a/ontology/update.py +++ b/ontology/update.py @@ -22,10 +22,12 @@ def find_path(parent, root=None, path=None): return r def get_node(name, children, parent=None): + children_ = [get_node(child, children[child], name) for child in children] + children_.sort(key=lambda c: c['name']) node = { "size": len(children) + 100, "name": name, - "children": [get_node(child, children[child], name) for child in children] + "children": children_ } if not node['children']: del node['children']