From faa1e984ab6f16d5535438c0c7b3a3cd3a8c1677 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 26 Jul 2022 01:58:11 +0200 Subject: [PATCH] Sort ports by name in the connnection-matrix This should fix a long-standing issue with interleaved display of clients since jack_get_ports() does not return a well defined order. (Internal backends based on Ardour::PortEngine keep ports sorted) --- gtk2_ardour/port_group.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc index a1694bb2c4..af2e8d1da2 100644 --- a/gtk2_ardour/port_group.cc +++ b/gtk2_ardour/port_group.cc @@ -26,6 +26,8 @@ #include "midi++/mmc.h" +#include "pbd/natsort.h" + #include "ardour/audio_port.h" #include "ardour/async_midi_port.h" #include "ardour/audioengine.h" @@ -583,6 +585,14 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp if (ports.size () > 0) { + struct SortByPortName { + bool operator() (std::string const& lhs, std::string const& rhs) const { + return PBD::naturally_less (lhs.c_str (), rhs.c_str ()); + } + } port_sorter; + + std::sort (ports.begin (), ports.end (), port_sorter); + for (vector::const_iterator s = ports.begin(); s != ports.end(); ++s) { std::string const p = *s;