list = {"dalawa":2, "tatlo":3, "apat":4, "siyam":5, "isa":1}
# look up lambda functions in order to better understand the below functionality.
# In short what this does is, return to the sorted function the values of keys in the above dictionary and telling it to sort by them and not by the actual via resetting the key parameter to the lambda function.
result = sorted(list, key=lambda x:list[x[0]])
python sort()方法将按字母顺序对列表进行排序。 您可以将每个菲律宾数字的值指定为字典,然后根据值对其进行排序
应该这样做:(我在编数值)
相关问题 更多 >
编程相关推荐