I can not figure out the order of dictionary keys, they seemed not to be sorted. Any insight?
bumsfeld 413 Nearly a Posting Virtuoso
Recommended Answers
Jump to PostAn example would be nice, one that surprises you by the outcome.
Jump to PostThis little test using your example will show you that dictionary keys do have a certain order ...
# these all give the same result = {'a': 1, 'c': 3, 'b': 2, 'd': 4} # so there must be a reason why keys are in a certain …
Jump to PostLook at it this way, a list assigns a numeric index to its elements. It starts at zero for the first element and then increases by one for each following element. To access the element you need to know this index number.
In the dictionary this index number has …
Jump to PostBy gosh, you got it! You may call this dictionary comprehension!
All 13 Replies
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
G-Do 19 Junior Poster
bumsfeld 413 Nearly a Posting Virtuoso
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
bumsfeld 413 Nearly a Posting Virtuoso
mawe 6 Junior Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
bumsfeld 413 Nearly a Posting Virtuoso
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
bumsfeld 413 Nearly a Posting Virtuoso
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
bumsfeld 413 Nearly a Posting Virtuoso
G-Do 19 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.