Fix crash when displaying some large loops

With the introduction of plenums, the branches on loops (air and plant,
supply and demand) are sorted alphabetically by the "primary" component
when they are displayed in the UI.  This seems to have introduced a bug
in large models where the app can crash.

[#66464624]