def format_traits(code, value):
    """Format traits as list of names.
    """
    result = []

    for trait in code:
        if value & code[trait]:
            result.append(trait)

    result.sort()
    return ','.join(result)