So I found how to sort a list of tuples in descending order, but I'm trying to figure out how to do sorting in ascending order, could somebody please help me with this (I'm stuck for quite a bit XD). Here is my code:
def Sort_Tuple(tup):
tup.sort(key=lambda x: x[1])
return tup
tup = [('A', 10), ('B', 5), ('C', 20), ('D', 15)]
print(Sort_Tuple(tup))
#RETURNS [('B', 5), ('A', 10), ('D', 15), ('C', 20)]
#I want [('C', 20), ('D', 15), ('A', 10), ('B', 5)]