Run
mylist = [('apple',84), ('banana',92) , ('cherry',88) , ('mango',86), ('lichi',89)] # Sort by first element of tuple ith = 0 list_length = len(mylist) for i in range(0, list_length): for j in range(0, list_length-i-1): if (mylist[j][ith] > mylist[j + 1][ith]): mylist[j], mylist[j + 1] = mylist[j + 1], mylist[j] print(mylist)
Output