Comment toCode() now uses template
Node toCode() sorts ports by type and by name