def sorted_allowed_list(allowed_list):
 allowed_by_protocol = sorted(allowed_list, key=(lambda x: x['IPProtocol']))
 return sorted(allowed_by_protocol, key=(lambda y: y['ports'].sort()))

def sorted_allowed_list ( allowed_list ) : allowed_by_protocol = sorted ( allowed_list , key = ( lambda x : x [ 'IPProtocol' ] ) ) return sorted ( allowed_by_protocol , key = ( lambda y : y [ 'ports' ] . sort ( ) ) )
sort allowed_list by protocol and port .