Get the App
SLTechnology News&Howtos  ›  Development  › 

How python sorts dictionaries

Shulou Source: shulou.com Published: 2022-06-01 04:49:37 09月22日 Update

This article mainly shows you "python how to sort dictionaries", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "python how to sort dictionaries" this article.

Sort dictionary (collections.OrderedDict)

> m = dict ((str (x), x) for x in range (10)) > > print "," .join (m.keys ()) 1,0,3,2,5,4,7,6,9,8 > > m = collections.OrderedDict ((str (x), x) for x in range (10)) > > print "," .join (m.keys ()) 0,1,2,3,4,5,6,7,8,9 > m = collections.OrderedDict (str (x), x) for x in range (10) 0,-1) > print "," .join (m.keys ()) 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 are all the contents of the article "how python sorts dictionaries" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Dictionary sort content article learning help easy to understand more organization knowledge editing industry information information channel channel research Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Docker NVidia OPPO Reno MySQL