From 993833dfcfa2e8a2f117387e2109261b26ec60bf Mon Sep 17 00:00:00 2001
From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com>
Date: Tue, 26 Apr 2022 14:53:44 +0200
Subject: [PATCH] Sort (in python) the mechanism names. (#1882)

---
 python/mechanism.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/python/mechanism.cpp b/python/mechanism.cpp
index 80db1030..a97d035d 100644
--- a/python/mechanism.cpp
+++ b/python/mechanism.cpp
@@ -113,7 +113,9 @@ void register_mechanisms(pybind11::module& m) {
     pybind11::class_<arb::mechanism_catalogue> cat(m, "catalogue");
 
     struct mech_cat_iter_state {
-        mech_cat_iter_state(const arb::mechanism_catalogue &cat_, pybind11::object ref_): names(cat_.mechanism_names()), ref(ref_), cat(cat_) { }
+        mech_cat_iter_state(const arb::mechanism_catalogue &cat_, pybind11::object ref_): names(cat_.mechanism_names()), ref(ref_), cat(cat_) {
+            std::sort(names.begin(), names.end());
+        }
         std::vector<std::string> names;      // cache the names else these will be allocated multiple times
         pybind11::object ref;                // keep a reference to cat lest it dies while we iterate
         const arb::mechanism_catalogue& cat; // to query the C++ object
-- 
GitLab