Skip to content

Commit

Permalink
Sort AICD templates based on ID
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 19, 2023
1 parent 9b797fd commit f680426
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,28 @@ void RicImportValveTemplatesFeature::onActionTriggered( bool isChecked )
}

// There can be multiple items of the same template, make sure we have unique templates
std::sort( aicdTemplates.begin(), aicdTemplates.end() );
std::sort( aicdTemplates.begin(),
aicdTemplates.end(),
[]( RiaOpmParserTools::AicdTemplateValues& templateA, RiaOpmParserTools::AicdTemplateValues& templateB )
{
int idA = 0;
int idB = 0;

auto itA = templateA.find( RiaOpmParserTools::aicdTemplateId() );
if ( itA != templateA.end() )
{
idA = itA->second;
}

auto itB = templateB.find( RiaOpmParserTools::aicdTemplateId() );
if ( itB != templateB.end() )
{
idB = itB->second;
}

return idA < idB;
} );

auto it = std::unique( aicdTemplates.begin(), aicdTemplates.end() );
aicdTemplates.resize( std::distance( aicdTemplates.begin(), it ) );

Expand Down

0 comments on commit f680426

Please sign in to comment.