Browse Source

Demo: Dual List Box: fix sorting function, in theory should return 0 when equal. (#8601)

ocornut 3 months ago
parent
commit
3f8033324f
1 changed files with 2 additions and 2 deletions
  1. 2 2
      imgui_demo.cpp

+ 2 - 2
imgui_demo.cpp

@@ -2491,7 +2491,7 @@ struct ExampleDualListBox
     {
     {
         const int* a = (const int*)lhs;
         const int* a = (const int*)lhs;
         const int* b = (const int*)rhs;
         const int* b = (const int*)rhs;
-        return (*a - *b) > 0 ? +1 : -1;
+        return (*a - *b);
     }
     }
     void SortItems(int n)
     void SortItems(int n)
     {
     {
@@ -2499,7 +2499,7 @@ struct ExampleDualListBox
     }
     }
     void Show()
     void Show()
     {
     {
-        //ImGui::Checkbox("Sorted", &OptKeepSorted);
+        //if (ImGui::Checkbox("Sorted", &OptKeepSorted) && OptKeepSorted) { SortItems(0); SortItems(1); }
         if (ImGui::BeginTable("split", 3, ImGuiTableFlags_None))
         if (ImGui::BeginTable("split", 3, ImGuiTableFlags_None))
         {
         {
             ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch);    // Left side
             ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch);    // Left side