ldict = [{'name':'Homer', 'age':39}, {'name':'Bart', 'age':10}]
newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])
import operator
newlist = sorted(list_to_be_sorted, key=operator.itemgetter('name'))
import operator
ldict.sort(key=operator.itemgetter('name'))
newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])
import operator
newlist = sorted(list_to_be_sorted, key=operator.itemgetter('name'))
import operator
ldict.sort(key=operator.itemgetter('name'))
No comments:
Post a Comment