#NEWLINE# def group_steps( steps ) : #NEWLINE# #INDENT# 'Group steps by type.' #NEWLINE# steps = sorted ( steps , key = ( lambda step : step . type ) ) #NEWLINE# seen_steps = set ( ) #NEWLINE# grouped_steps = [ ] #NEWLINE# for step in itertools . chain . from_iterable ( ( sorted ( group , key = ( lambda step : step . name ) ) for ( _ , group ) in itertools . groupby ( steps , ( lambda step : step . type ) ) ) ) : #NEWLINE# #INDENT# if ( step . name not in seen_steps ) : #NEWLINE# #INDENT# grouped_steps . append ( step ) #NEWLINE# seen_steps . add ( step . name ) #NEWLINE# #UNINDENT# #UNINDENT# grouped_steps . sort ( key = ( lambda step : STEP_TYPES . index ( step . type ) ) ) #NEWLINE# return grouped_steps