First, you need to install the package through the PIP Install operator, itemGetter can sort multiple fields with type int. The code snippet is as follows:

from operator import itemgetter

d = [
    {"name": '李一'.'chinese': 66, 'mathematics': 98},
    {'name': 'the king 2'.'chinese': 99, 'mathematics': 68},
    {'name': 'Joe'.'chinese': 88, 'mathematics': 78},
    {'name': 'Liu Si'.'chinese': 88, 'mathematics': 99}]Sort sorted by sorted:
s = sorted(d, key=lambda x: x['chinese'], reverse=True)

Sort by using the sorted method +itemgetter
ss = sorted(d, key=itemgetter('chinese'.'mathematics'), reverse=True)

Sort by sort
d.sort(key=lambda x: x['chinese'], reverse=True)
Copy to SS by slice
sss = d[:]  

print(s)
print(ss)
print(sss)
Copy the code