code: def sort(lines):  # type: (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
docs: Sort a YAML file in alphabetical order, keeping blocks together.
  
      :param lines: array of strings (without newlines)
      :return: sorted array of strings