From c879dcaf7d360bf74128292f8015a0d854b8a710 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 21 Aug 2019 20:16:21 +0100 Subject: [PATCH] Sort pins by number when grouping by name. Fixes: lp:1828648 * https://bugs.launchpad.net/kicad/+bug/1828648 (cherry picked from commit 97212acecb87f1ba27a7e644a898eddb5ca46fc4) --- eeschema/dialogs/dialog_lib_edit_pin_table.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 2cbc0a5a68..8e084f7ebf 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -309,6 +309,9 @@ public: ascending = GetView()->IsSortOrderAscending(); } + for( LIB_PINS& row : m_rows ) + SortPins( row ); + SortRows( sortCol, ascending ); if ( GetView() ) @@ -321,8 +324,19 @@ public: void SortRows( int aSortCol, bool ascending ) { std::sort( m_rows.begin(), m_rows.end(), - [ aSortCol, ascending, this ]( LIB_PINS lhs, LIB_PINS rhs ) -> bool - { return compare( lhs, rhs, aSortCol, ascending, m_userUnits ); } ); + [ aSortCol, ascending, this ]( LIB_PINS& lhs, LIB_PINS& rhs ) -> bool + { + return compare( lhs, rhs, aSortCol, ascending, m_userUnits ); + } ); + } + + void SortPins( LIB_PINS& aRow ) + { + std::sort( aRow.begin(), aRow.end(), + []( LIB_PIN* lhs, LIB_PIN* rhs ) -> bool + { + return PinNumbers::Compare( lhs->GetNumber(), rhs->GetNumber() ) < 0; + } ); } void AppendRow( LIB_PIN* aPin )