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();
auto back_rank = std::count_if(selections.begin(), selections.end(),
[&](const Selection& sel)
{ return sel.begin() < back.begin(); });
std::sort(selections.begin(), selections.end(), compare_selections);
{ return sel.begin() <= back.begin(); });
std::stable_sort(selections.begin(), selections.end(), compare_selections);
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());
assert(selections.back() == back);