def sort_canonical(keyword, stmts):
    try:
        (_arg_type, subspec) = stmt_map[keyword]
    except KeyError:
        return stmts
    res = []
    keep = [s[0] for s in data_def_stmts] + ['case']
    for (kw, _spec) in flatten_spec(subspec):
        comments = []
        for s in stmts:
            if s.keyword == '_comment':
                comments.append(s)
            elif s.keyword == kw and kw not in keep:
                res.extend(comments)
                comments = []
                res.append(s)
            else:
                comments = []
    res.extend([stmt for stmt in stmts if stmt not in res])
    return res