Skip to content

Commit

Permalink
Sort alternatives in requirement_data::list_all
Browse files Browse the repository at this point in the history
Want to use this output in tests, and it's helpful for it to be more
consistent.
  • Loading branch information
jbytheway committed Jan 7, 2020
1 parent 9ea9f81 commit 9ee199e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/requirements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,13 @@ std::string requirement_data::print_all_objs( const std::string &header,
if( !buffer.empty() ) {
buffer += std::string( "\n" ) + _( "and " );
}
for( auto it = list.begin(); it != list.end(); ++it ) {
if( it != list.begin() ) {
buffer += _( " or " );
}
buffer += it->to_string();
}
std::vector<std::string> alternatives;
std::transform( list.begin(), list.end(), std::back_inserter( alternatives ),
[]( const T & t ) {
return t.to_string();
} );
std::sort( alternatives.begin(), alternatives.end() );
buffer += join( alternatives, _( " or " ) );
}
if( buffer.empty() ) {
return std::string();
Expand Down

0 comments on commit 9ee199e

Please sign in to comment.