<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def issuetypes(accountable, project_key):
 """ List all issue types. Optional parameter to list issue types by a given project. """

    projects = accountable.issue_types(project_key)
    headers = sorted(['id', 'name', 'description'])
    rows = []
    for key, issue_types in sorted(projects.items()):
        for issue_type in issue_types:
            rows.append(
                [key] + [v for k, v in sorted(issue_type.items())
                         if k in headers]
            )
    rows.insert(0, ['project_key'] + headers)
    print_table(SingleTable(rows))