So I have this list, we\'ll call it listA. I\'m trying to get the [3] item in each list e.g. [\'5.01\',\'5.88\',\'2.10\',\'9.45\',\'17.58\',\'2.76\'] in sorted orde
[\'5.01\',\'5.88\',\'2.10\',\'9.45\',\'17.58\',\'2.76\']
An anonymous lambda function is not necessary for this task. You can use operator.itemgetter, which may be more intuitive:
lambda
operator.itemgetter
from operator import itemgetter res1 = sorted(map(itemgetter(3), listA), reverse=True, key=float) ['17.58', '9.45', '5.88', '5.01', '2.76', '2.10']