From 2be599af63dbe4d750c12cdad1737fae4628c64d Mon Sep 17 00:00:00 2001 From: btrotta Date: Wed, 14 Aug 2019 20:19:58 +1000 Subject: [PATCH] Use stable sort. --- src/io/bin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/bin.cpp b/src/io/bin.cpp index 2556a59b4715..b26a6a461e3e 100644 --- a/src/io/bin.cpp +++ b/src/io/bin.cpp @@ -213,7 +213,7 @@ namespace LightGBM { if (num_to_insert > 0) { bin_upper_bound.insert(bin_upper_bound.end(), forced_upper_bounds.begin(), forced_upper_bounds.begin() + num_to_insert); } - std::sort(bin_upper_bound.begin(), bin_upper_bound.end()); + std::stable_sort(bin_upper_bound.begin(), bin_upper_bound.end()); // find remaining bounds std::vector bounds_to_add; @@ -238,7 +238,7 @@ namespace LightGBM { bounds_to_add.insert(bounds_to_add.end(), new_upper_bounds.begin(), new_upper_bounds.end() - 1); // last bound is infinity } bin_upper_bound.insert(bin_upper_bound.end(), bounds_to_add.begin(), bounds_to_add.end()); - std::sort(bin_upper_bound.begin(), bin_upper_bound.end()); + std::stable_sort(bin_upper_bound.begin(), bin_upper_bound.end()); CHECK(bin_upper_bound.size() <= max_bin); return bin_upper_bound; }