I'm creating a script in python that gets the user's name and lap time, it then saves it into a dictionary which then saves it to a file. How do I sort the dictionary so it shows the lowest numbers first and then the four more scores after that?
def lap():
username = str(input("Name: "))
time = str(input("Lap Time: "))
lap_det = {}
lap_det = str([username + " : " + time])
with open("lap_time.txt", "w") as f:
f.write(lap_det)
with open("lap_time.txt", "r") as f:
print(f.readlines())
user_r = input("Press r to restart >>> ")
if user_r == "r":
lap()
else:
quit()
lap()