Fix sort_and_merge_overlapping

This commit is contained in:
Maxime Coste 2013-01-17 18:46:45 +01:00
parent 3f01f4bdf5
commit 44ca4d23de

View File

@ -142,10 +142,10 @@ static void sort_and_merge_overlapping(SelectionList& selections)
Range back = selections.back(); Range back = selections.back();
auto back_rank = std::count_if(selections.begin(), selections.end(), auto back_rank = std::count_if(selections.begin(), selections.end(),
[&](const Selection& sel) [&](const Selection& sel)
{ return sel.begin() < back.begin(); }); { return sel.begin() <= back.begin(); });
std::sort(selections.begin(), selections.end(), compare_selections); std::stable_sort(selections.begin(), selections.end(), compare_selections);
if (back_rank < selections.size() - 1) if (back_rank < selections.size() - 1)
std::rotate(selections.begin(), selections.begin() + back_rank + 1, std::rotate(selections.begin(), selections.begin() + back_rank,
selections.end()); selections.end());
assert(selections.back() == back); assert(selections.back() == back);