From 9524ddda3f75d7a9524af311075d6033aee54651 Mon Sep 17 00:00:00 2001 From: Anil Sorathiya Date: Wed, 23 Apr 2025 10:27:20 +0100 Subject: [PATCH] keep order of the sections while previewing the template --- validmind/template.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/validmind/template.py b/validmind/template.py index 315b9449a..10517f877 100644 --- a/validmind/template.py +++ b/validmind/template.py @@ -53,8 +53,9 @@ def _convert_sections_to_section_tree( if start_section_id and not section_tree: raise ValueError(f"Section {start_section_id} not found in template") - - return sorted(section_tree, key=lambda x: x.get("order", 0)) + # sort the section tree by the order of the sections in the template (if provided) + # set the order to 9999 for the sections that do not have an order + return sorted(section_tree, key=lambda x: x.get("order", 9999)) def _create_content_widget(content: Dict[str, Any]) -> Widget: