From 3f8033324fbe5dbd3a47e91b02556c91b7d6ce1f Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 30 Apr 2025 11:10:54 +0200 Subject: [PATCH] Demo: Dual List Box: fix sorting function, in theory should return 0 when equal. (#8601) --- imgui_demo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index c7d3a31bc..24ea67fa2 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2491,7 +2491,7 @@ struct ExampleDualListBox { const int* a = (const int*)lhs; const int* b = (const int*)rhs; - return (*a - *b) > 0 ? +1 : -1; + return (*a - *b); } void SortItems(int n) { @@ -2499,7 +2499,7 @@ struct ExampleDualListBox } void Show() { - //ImGui::Checkbox("Sorted", &OptKeepSorted); + //if (ImGui::Checkbox("Sorted", &OptKeepSorted) && OptKeepSorted) { SortItems(0); SortItems(1); } if (ImGui::BeginTable("split", 3, ImGuiTableFlags_None)) { ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch); // Left side