def sort_lines(input_file, output_file): | |
with open(input_file, 'r') as file: | |
lines = file.readlines() | |
sorted_lines = sorted(lines) | |
with open(output_file, 'w') as file: | |
for line in sorted_lines: | |
file.write(line) | |
if __name__ == "__main__": | |
import sys | |
if len(sys.argv) != 2: | |
print("Usage: python sort_lines.py <input_file>") | |
sys.exit(1) | |
input_file = sys.argv[1] | |
output_file = 'output_sorted.txt' | |
sort_lines(input_file, output_file) |