Currently I have a list, which represent the student with their test scores
a = [['May', 81], ['Jack', 91], ['Mike', 52], ['Jeremy', 58], ['Mark', 71],['Sam',81],['Brian',61],['Yan',71]]
I wish to use selection sort to sort the scores first then the student name in alphabetic order.
I am a beginner and only know how to sort a normal list like
a = [1,64,23,13]
will give: a = [1,13,23,64]
My selection sort code is here:
def sort(a):
for i in range(len(a)):
min_item = min(a[i:])
index = a.index(min_item)
a[i],a[index] = a[index],a[i]
print(a)
How can i sort the scores first then the name?