s = sorted(s, key = lambda x: (x[1], x[2]))
mylist = sorted(mylist, key=itemgetter('name', 'age'))
mylist = sorted(mylist, key=lambda k: (k['name'].lower(), k['age']))
mylist = sorted(mylist, key=lambda k: (k['name'].lower(), -k['age']))
records.sort(
key = lambda l: (l[0], l[2])
)
a_list = ["aaa", "cc", "bb"]
new_list = sorted(a_list, key=lambda x: (len(x), x))
#Sort by length then alphabetically
print(new_list)
#OUTPUT
#>>['bb', 'cc', 'aaa']
>>> def multisort(xs, specs):
... for key, reverse in reversed(specs):
... xs.sort(key=attrgetter(key), reverse=reverse)
... return xs