I have a .txt
file that has the following information in it that displays a users name and then 3 scores that they have scored in a quiz:
callum,10,7,9
carl,10,10,10
hollie,1,4,7
brad,4,8,3
kyle,7,2,0
I would like to sort
it into alphabetical order displaying the users highest score after their name.
readlines()
method to read lines from file.split()
to get Name and score.Name
isKey
andValue
is total score.keys
from the result dictionary.sort()
method to sort list by alphabets.Code
Output:
So i would first of all isolate all the lines:
So i will continue assuming I have a list called lines with the following content:
Then I will firstly sort the line by name
Then for each line you want to isolate the marks, sort them and print them back: