链接地址:6188. 按身高排序
根据字典降序排列输出键值,之后输出names序列
class Solution:
def sortPeople(self, names: List[str], heights: List[int]) -> List[str]:
hash_map={}
res: List[str] = []
for i in range(len(heights)):
hash_map[i] = heights[i]
# print(sorted(hash_map,reverse=True))
new_sys1 = sorted(hash_map.items(), key=lambda d: d[1], reverse=True)
print(new_sys1)
for key,val in new_sys1:
res.append(names[key])
# print(key)
# print(height)
return res
版权声明:本文为zjw120原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。