Index: tools/sort_sources.py |
diff --git a/tools/sort_sources.py b/tools/sort_sources.py |
index 60d388100f387ab462272c074a0f63d17942714a..63f1afdb6d7e7d338d8605cc7fe2c40ab2c2fb78 100755 |
--- a/tools/sort_sources.py |
+++ b/tools/sort_sources.py |
@@ -49,14 +49,16 @@ def SortSources(original_lines): |
sources.append([line, comments]) |
comments = [] |
else: |
- if comments: |
- output_lines.extend(comments) |
- comments = [] |
+ # |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 |