From d8b3fc84c2239effb1824e7094c7bf24db45a7ba Mon Sep 17 00:00:00 2001 From: Daniel Kulp Date: Wed, 24 Jan 2018 23:40:36 +0100 Subject: [PATCH] Fix sorting in generic wxDataViewCtrl broken by recent changes The comparator used with std::sort() must return true only if the first item is strictly less than the second one, this is a requirement of the sorting algorithm and not respecting it results in wrong final order. See https://github.com/wxWidgets/wxWidgets/pull/642 --- src/generic/datavgen.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index ad336e3067..c06e72fc11 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1666,12 +1666,11 @@ public: m_sortOrder.IsAscending()); } - // Return true if the items are in order, i.e. the first item is less than - // or equal (because it's useless to exchange them in this case) than the - // second one. This is used by std::sort(). + // Return true if the items are (strictly) in order, i.e. the first item is + // less than the second one. This is used by std::sort(). bool operator()(wxDataViewTreeNode* first, wxDataViewTreeNode* second) const { - return Compare(first, second) <= 0; + return Compare(first, second) < 0; } private: