Python 是否可以对代表菲律宾数字的字符串列表进行排序

Python 是否可以对代表菲律宾数字的字符串列表进行排序,python,Python,list=[dalawa,tatlo,apat,siyam,isa],是否有方法将其排序为list=[isa,dalawa,tatlo,apat,siyam]。我在python中遇到了一个新问题,所以我对此一无所知。python sort()方法将按字母顺序对列表进行排序。 您可以将每个菲律宾数字的值指定为字典,然后根据值对其进行排序 应该这样做:(我在编数值) 这回答了你的问题吗?很抱歉,我不知道如何根据它的值对它进行排序,它只能返回字典中的键。 list = {"dalawa&qu

list=[dalawa,tatlo,apat,siyam,isa],是否有方法将其排序为list=[isa,dalawa,tatlo,apat,siyam]。我在python中遇到了一个新问题,所以我对此一无所知。

python sort()方法将按字母顺序对列表进行排序。 您可以将每个菲律宾数字的值指定为字典,然后根据值对其进行排序

应该这样做:(我在编数值)


这回答了你的问题吗?很抱歉,我不知道如何根据它的值对它进行排序,它只能返回字典中的键。
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]])