Skip to content

Commit b5087de

Browse files
committed
Make 'order_by_priority' deterministic
There's currently no defined order for two issues with the same priority and section tag. Depending on the implementation of std::sort, the results can vary. Include the issue ID in the order, to get a total order for all issues.
1 parent 0e606a8 commit b5087de

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/report_generator.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ struct order_by_priority {
117117
auto operator()(lwg::issue const & x, lwg::issue const & y) const -> bool {
118118
assert(!x.tags.empty());
119119
assert(!y.tags.empty());
120-
return x.priority == y.priority
121-
? section_db.get()[x.tags.front()] < section_db.get()[y.tags.front()]
122-
: x.priority < y.priority;
120+
auto tie = [this](auto& i) {
121+
return std::tie(i.priority, section_db.get()[i.tags.front()], i.num);
122+
};
123+
return tie(x) < tie(y);
123124
}
124125

125126
private:

0 commit comments

Comments
 (0)