I have a list of tuples, where each tuple(a,b) represents the height of an object a*b:
L = [("3m", "5cm"), ("10m", "77cm"), ("1m", "82cm"), ("1m", "74cm"), ("11m", "50cm")]
Now, I want to sort this list based on height using a lambda sort function. The output is supposed to look as follows:
L = [("1m", "74cm"), ("1m", "82cm"), ("3m", "5cm"), ("10m", "77cm"), ("11m", "50cm")]
The follwing is what I tried, but I am getting errors:
L.sort(key= lambda x: 100 * int(x[0][0:-2]) + int(x[1][0:-3]))
How can it be fixed?