Hi Sammy, Try this this may help you !
---------------------------------------------------------------------------------- def sort_file1_to_file2(file1, file2): """.""" input_content = [] with open(file1, 'r') as fp: input_content = fp.read() input_content = input_content.splitlines() _dict = {ele[0].lower(): ele for ele in input_content} out_content = "\n".join([_dict[chr(idx)] for idx in range(97, 123) if chr(idx) in _dict]) with open(file2, 'w') as fp: fp.write(out_content) sort_file1_to_file2('file1.txt', 'file2.txt') ------------------------------------------------------------------------------------ *-- Regards --* * * * Siva Cn* *Python Developer* * * *http://www.cnsiva.com* ---------------------
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor