The sort() function is actually an instance method of the list data type, such that the userage is list.sort()
The sorting operation byy sort() is in place and returns None. type(nums.sort())
sorted allows the argument to be a list of any other iterable objects
a lambda in Python is just an anonymous function that has one or more arguments, but only one expression.
sorted_activities = sorted(df, key=lambda x: x['col1'], reversed = True)
sorted_activities = sorted(df, key=lambda x: x'['col1', 'col2'], reversed = True)
from operator import itemgetter
sorted_activities = sorted(activities, key=itemgetter('day', 'activity'), reverse=True)
No comments:
Post a Comment