parameters: (original_lines)
return_statement: return output_lines
docstring: Sort source file names in |original_lines|.
  
    Args:
      original_lines: Lines of the original content as a list of strings.
  
    Returns:
      Lines of the sorted content as a list of strings.
  
    The algorithm is fairly naive. The code tries to find a list of C-ish
    source file names by a simple regex, then sort them. The code does not try
    to understand the syntax of the build files. See the file comment above for
    details.
docstring_summary: Sort source file names in |original_lines|.
docstring_tokens: Sort source file names in |original_lines| .
function: def SortSources(original_lines):
    """Sort source file names in |original_lines|.
  
    Args:
      original_lines: Lines of the original content as a list of strings.
  
    Returns:
      Lines of the sorted content as a list of strings.
  
    The algorithm is fairly naive. The code tries to find a list of C-ish
    source file names by a simple regex, then sort them. The code does not try
    to understand the syntax of the build files. See the file comment above for
    details.
    """
  
    output_lines = []
    comments = []
    sources = []
    for line in original_lines:
      if re.search(COMMENT_PATTERN, line):
        comments.append(line)
      elif re.search(SOURCE_PATTERN, line):
        # Associate the line with the preceding comments.
        sources.append([line, comments])
        comments = []
      else:
        # |sources| should be flushed first, to handle comments at the end of a
        # source list correctly.
        if sources:
          for source_line, source_comments in sorted(sources):
            output_lines.extend(source_comments)
            output_lines.append(source_line)
          sources = []
        if comments:
          output_lines.extend(comments)
          comments = []
        output_lines.append(line)
    return output_lines
function_tokens: def SortSources ( original_lines ) : output_lines = [ ] comments = [ ] sources = [ ] for line in original_lines : if re . search ( COMMENT_PATTERN , line ) : comments . append ( line ) elif re . search ( SOURCE_PATTERN , line ) : # Associate the line with the preceding comments. sources . append ( [ line , comments ] ) comments = [ ] else : # |sources| should be flushed first, to handle comments at the end of a # source list correctly. if sources : for source_line , source_comments in sorted ( sources ) : output_lines . extend ( source_comments ) output_lines . append ( source_line ) sources = [ ] if comments : output_lines . extend ( comments ) comments = [ ] output_lines . append ( line ) return output_lines