Hello. I want to modify and sort but it’s only modifying why is it not searching?
std_file = open("students.txt", "r") #reading the contents in students.txt file std_records = std_file.readlines() #readlines() return all lines in the file, as a list where each line is an item in the list object record = 0 for std_record in std_records: print("[",(record+1),"]",std_record.strip()) #printing each line from text file record+=1 record_num=int(input("\nEnter record number you wanted to edit: ")) print() std_details = std_records[record_num-1].split(",") #value of selected record from text file transfer to std_details list variable record = 0 for std_record in new_list: print("[",(record+1),"]",std_record.strip()) #printing each line from text file record+=1 element = 0 for record_element in std_details: print("[",(element+1),"]",record_element) #printing the selected record details element+=1 element_number=int(input("Enter element number you wanted to edit: ")) print("\nCurrent element value:",std_details[element_number-1]) new_element_value = input("Enter new element value: ") new_line="" if element_number==4 and record!=record_num: new_line="\n" #to be added when updating the record in text file, so each record separated by new line std_details[element_number-1] = new_element_value+new_line #assigning new value into selected element updated_record = ','.join(std_details) #join() method takes all items in a list and joins them into one string. updated_record is a string std_records[record_num-1] = updated_record #now selected line has updated value new_list =  while std_records: minimum = std_records for x in std_records: if x < minimum: minimum = x new_list.append(minimum) std_records.remove(minimum) print() print("Sorted:") with open("students.txt", "w") as file: file.writelines(std_records) #writing the updated student records into text file print("\nRecord updated!") std_file.close()