Write a Python function that reads an input file and creates asorted output file. The function is file_sort(infile, outfile).Function takes the file names as parameters. Input file containsstudent info and has the following format. The first line containsthe number of students in the file. Each subsequent line containsinfo about one student. Each line contains 3 fields namely studentid, name, and gpa in that order separated by a blank. The studentid is a positive integer. The name is a single word string. Gpa isa double type. Function sorts the student info in ascending orderby student id. The ordered student info is written to output file.The output file has the same format as the input file.
Expert Answer
Answer to Write a Python function that reads an input file and creates a sorted output file. The function is file_sort(infile, out…