Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8866895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:53:38+00:00 2026-06-14T16:53:38+00:00

Based on what I know, you can’t assume that a data structure (such as

  • 0

Based on what I know, you can’t assume that a data structure (such as dictionary) will save the values in it on the same order as what you have initialized it.
For example:

d = {1:10,2:20,3:30}

when you print it inside a for loop, the result could be:

{2:20,1:10,3:30}

Why it happens – why the dictionary (or the other data structure) won’t keep the values in a specific order?
Is it true only for dictionaries?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:53:38+00:00Added an answer on June 14, 2026 at 4:53 pm

    Among the Python builtin types, it’s true for dictionaries and sets. Lists and tuples preserve order. There is collections.OrderedDict for an ordered version of a dictionary. For other types (e.g., ones from libraries that aren’t built into Python), you just have to read the documentation. There’s no general rule for what a “data structure” does in Python. You have to look at the documentation of each type to understand what behavior it does or doesn’t define.

    Python does define the notion of “sequence”, which is defined to have order (lists and tuples are sequences). A dictionary is a “mapping”, which needn’t have order. (See the Python glossary and the collections module for more info.)

    As to why, it’s just how dictionaries were implemented. Basically they can be faster if they don’t have to keep track of order, and in many cases you don’t care about the order, so they were implemented as unordered collections for efficiency.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of a diff viewer or comparison program that can do paragraph-based
i would like to know if i can develop a OpenSocial based application for
I am developing an quiz based application. I wanted to know like, how can
Yes, I know that downcast using dynamic_cast can't compile if the Base is not
Does anyone know of a bug tracking piece of software that has community based
Does anyone know how can I do a count in SQL Server based on
I would like to know how can I select <span =data> from the following.
I know you can do redirection based on the domain or path to rewrite
I would like to know how can I start a crawler based on Scrapy.
Does anyone know how can I get next week date based on this week

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.