Answers for "operator.itemgetter(1) in python"

1

operator.itemgetter(1) in python

sorted(movies, key=itemgetter('date'))#equivalent to "sorted(movies, key = lambda x: x['date'])"Output: [{'name': 'Avengers: Age of Ultron', 'date': '24/4/2013'}, {'name': 'Iron Man 3', 'date': '26/4/2013'}, {'name': 'Avengers Endgame', 'date': '26/4/2019'}]
Posted by: Guest on October-04-2021

Python Answers by Framework

Browse Popular Code Answers by Language