From 0091f5c09b17f644870f66d8d1afb00ee995f2c0 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 23 Sep 2024 12:25:29 +0500 Subject: [PATCH] Simplify spatial elements sorting --- src/bonsai/bonsai/tool/spatial.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/tool/spatial.py b/src/bonsai/bonsai/tool/spatial.py index d9442bd356..258d494224 100644 --- a/src/bonsai/bonsai/tool/spatial.py +++ b/src/bonsai/bonsai/tool/spatial.py @@ -453,9 +453,10 @@ class Spatial(bonsai.core.tool.Spatial): new.level_index = level_index children = ifcopenshell.util.element.get_parts(element) if children: - children_elevations = [ifcopenshell.util.placement.get_storey_elevation(el) for el in children] - children_names = [el.Name or "" for el in children] - children = natsorted(children, key=dict(zip(children, tuple(zip(children_elevations, children_names)))).get) + children = natsorted( + children, + key=lambda element: (ifcopenshell.util.placement.get_storey_elevation(element), element.Name), + ) new.has_children = bool(children) new.ifc_definition_id = element.id() if new.is_expanded: