テキストファイルの内容をソートするプログラム その1

その1なので例外処理も何もしていませんが、
CSV形式の並び替えには十分使えます。


file_path = ARGV[0]

read_file = open(file_path)
write_file = open("result_" + file_path, "w")

temp_lines = []
read_file.each do |line|
temp_lines << line
end

temp_lines.sort!

temp_lines.each do |line|
write_file.puts line
end

read_file.close
write_file.close

追記:並び替えは、辞書式で行われます。