nodes: 0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, comment:# type: (List[str]) -> List[str]; 5, block; 6, identifier:lines; 7, expression_statement; 8, comment:# make a copy of lines since we will clobber it; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:"""Sort a YAML file in alphabetical order, keeping blocks together.
  
      :param lines: array of strings (without newlines)
      :return: sorted array of strings
      """; 14, assignment; 15, assignment; 16, identifier:block; 17, call; 18, block; 19, identifier:new_lines; 20, identifier:lines; 21, call; 22, identifier:new_lines; 23, call; 24, identifier:sorted; 25, argument_list; 26, if_statement; 27, expression_statement; 28, identifier:list; 29, argument_list; 30, identifier:parse_block; 31, argument_list; 32, call; 33, keyword_argument; 34, identifier:new_lines; 35, block; 36, call; 37, identifier:lines; 38, identifier:lines; 39, keyword_argument; 40, identifier:parse_blocks; 41, argument_list; 42, identifier:key; 43, identifier:first_key; 44, expression_statement; 45, attribute; 46, argument_list; 47, identifier:header; 48, True; 49, identifier:lines; 50, call; 51, identifier:new_lines; 52, identifier:extend; 53, identifier:block; 54, attribute; 55, argument_list; 56, identifier:new_lines; 57, identifier:append; 58, string
code: def sort(lines):  # type: (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