diff --git a/misago/categories/proxy.py b/misago/categories/proxy.py index e005a9a083..6a97ae2d4a 100644 --- a/misago/categories/proxy.py +++ b/misago/categories/proxy.py @@ -38,6 +38,13 @@ def get_categories_menu(self) -> list[dict]: elif category["parent_id"] in children: children[category["parent_id"]].append(category) + # Sort top categories by lft to maintain order + top_categories.sort(key=lambda c: c["lft"]) + + # Sort child categories by lft to maintain order + for child_list in children.values(): + child_list.sort(key=lambda c: c["lft"]) + # Flatten menu for React.js menu_items: list[dict] = [] for category in top_categories: