Today I'm in a silence. I can't persuade my heart to let it go,MiMi.
Fortunately,I have mind,so it can be faded with time going.
Go Go Go
- The below is code of sort ,I can debug the whole project tomorrow.
![](https://content.hackertalk.net/pub/GMlwNd-aKJ6mWd
#This fuction is sort by grades
def sort():
show()
if os.path.exists(filename): # check whecher the file exists
with open(filename,'r') as file: # open with read only
student_old = file.readlines()
student_new = []
for list in student_old :
d = dict(eval(list))# string turn into dictionary
student_new.append(d) # add to new list
else:
retutn
ascORdesc = input("Please make a choose:(0 Ascending order 1 Descending order):")
if ascORdesc == "0":
ascORdescBool = False
elif ascORdesc =="1":
ascORdescBool = True
else:
print("Your input is incurrect,please inter again:")
sort()
mode = input("Please select the way of sort(1.sort by English grade, 2.sort by Python grade , 3.sort by C grade, 0.sort by total grades):")
if mode == "1":
student_new.sort(key=lambda x:x["english"],reverse=ascORdescBool)
elif mode=="2":
student_new.sort(key=lambda x:x["Python"],reverse=ascORdescBool)
elif mode =="3":
student_new.sort(key=lambda x:x["C"],revewse = ascORdesBool)
elif mode =="0":
student_new.sort(key=lambda x:x["english"]+x["Python"]+x["C"],reverse=ascORdescBool)
else:
print("Your input is incurrect,please enter again:")
sort()
show_student(student_new) # show the result of sort
print("Ok")