If you want to sort a list of tuples by 2nd item in ascending order you can do by using the sorted function. Below is the code for the same which shows how to do it.
sorted([('abc', 121),('abc', 231),('abc', 148), ('abc',221)], key=lambda x: x)
In the above code, the key is a function that identifies how to retrieve the comparable element from your data structure. So you are using the second element of the tuple.
Another good way of doing this by using the itemgetter function.
from operator import itemgetter
data = [('abc', 121),('abc', 231),('abc', 148), ('abc',221)] sorted(data,key=itemgetter(1))