如何按鍵對字典進行排序? - How can I sort a dictionary by key?

問題:

What would be a nice way to go from {2:3, 1:89, 4:5, 3:0} to {1:89, 2:3, 3:0, 4:5} ?{2:3, 1:89, 4:5, 3:0}{1:89, 2:3, 3:0, 4:5}什麼?
I checked some posts but they all use the "sorted" operator that returns tuples.我檢查了一些帖子,但它們都使用返回元組的“排序”運算符。


解決方案:

參考一: https://en.stackoom.com/question/blhd
參考二: https://stackoom.com/question/blhd
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章