person = {"li":18,"wang":50,"zhang":20,"sun":22}
person_age_min = min(person, key=person.get)
print(person_age_min)
person_age_max = max(person, key=person.get)
print(person_age_max)
person_sort = sorted(person, key=person.get)
print(person_sort)
person_re_sort = sorted(person, key=person.get,reverse=True)
print(person_re_sort)
#运行结果
li
wang
['li', 'zhang', 'sun', 'wang']
['wang', 'sun', 'zhang', 'li']
网友评论