(lines: List[str])
return new_lines
Sort a YAML file in alphabetical order, keeping blocks together.

    :param lines: array of strings (without newlines)
    :return: sorted array of strings
Sort a YAML file in alphabetical order, keeping blocks together.
Sort a YAML file in alphabetical order keeping blocks together .
def sort(lines: List[str]) -> List[str]:
    """Sort a YAML file in alphabetical order, keeping blocks together.

    :param lines: array of strings (without newlines)
    :return: sorted array of strings
    """
    # make a copy of lines since we will clobber it
    lines = list(lines)
    new_lines = parse_block(lines, header=True)

    for block in sorted(parse_blocks(lines), key=first_key):
        if new_lines:
            new_lines.append('')
        new_lines.extend(block)

    return new_lines
def sort ( lines : List [ str ] ) -> List [ str ] : # make a copy of lines since we will clobber it lines = list ( lines ) new_lines = parse_block ( lines , header = True ) for block in sorted ( parse_blocks ( lines ) , key = first_key ) : if new_lines : new_lines . append ( '' ) new_lines . extend ( block ) return new_lines