Group comments by the round to which they belong

def group_comments_by_round(comments, ranking=0):
    """
    Group comments by the round to which they belong
    """
    comment_rounds = {}
    ordered_comment_round_names = []
    for comment in comments:
        comment_round_name = ranking and comment[11] or comment[7]
        if comment_round_name not in comment_rounds:
            comment_rounds[comment_round_name] = []
            ordered_comment_round_names.append(comment_round_name)
        comment_rounds[comment_round_name].append(comment)
    return [(comment_round_name, comment_rounds[comment_round_name])
            for comment_round_name in ordered_comment_round_names]