3 ms·
well, in this particular case, operator.itemgetter is your friend :D import operator def get_users_by_posts(): return sorted(users, key=operat
by _ZeD_ 14y ago
well, in this particular case, operator.itemgetter is your friend :D
import operator
def get_users_by_posts():
return sorted(users, key=operator.itemgetter(1))
then, if you really want to, you can use functools.partial to fill the parameters
from functools import partial
from operator import itemgetter
get_users_by_posts = partial(sorted, users, key=itemgetter(1))