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

  • Home
  • SEARCH
  • 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 8465675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:07:06+00:00 2026-06-10T15:07:06+00:00

for i want to decode a dict to json,but i found the output order

  • 0

for i want to decode a dict to json,but i found the output order is not i desired,then i do a test like this:

a = {'a':'1st','ab':'2nd'}
print(a)
a = {'b':'1st','bc':'2nd'}
print(a)
a = {'c':'1st','cd':'2nd'}
print(a)
a = {'d':'1st','de':'2nd'}
print(a)
a = {'e':'1st','ef':'2nd'}
print(a)
a = {'f':'1st','fg':'2nd'}
print(a)

out put is

{'a': '1st', 'ab': '2nd'}
{'b': '1st', 'bc': '2nd'}
{'c': '1st', 'cd': '2nd'}
{'de': '2nd', 'd': '1st'}
{'ef': '2nd', 'e': '1st'}
{'fg': '2nd', 'f': '1st'}

because d is 100 in ascii?

how to explain it?can i change the iter order?

  • 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-10T15:07:07+00:00Added an answer on June 10, 2026 at 3:07 pm

    Dictionaries aren’t sorted in Python. If you want sorted dictionaries, use OrderedDict:

    >>> from collections import OrderedDict
    >>> a = OrderedDict((('f','1st'),('fg','2nd')))
    >>> a
    OrderedDict([('f', '1st'), ('fg', '2nd')])
    

    In order to construct an OrderedDict, however, you need to use an object that preserves its sort order, like a list or a tuple.

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

Sidebar

Related Questions

i Want to fetch this data using json decode. Please Help.. So far i
i have this JSON string that i want to decode it with json_decode(); function
I have a unicode string like '%C3%A7%C3%B6asd+fjkls%25asd' and I want to decode this string.
look at that: import urllib print urllib.urlencode(dict(bla='Ã')) the output is bla=%C3%BC what I want
I want to include a php file in one another and decode the JSON
I want to decode JPEG files and obtain uncompressed decoded output in BMP/RGB format.I
I have a string and I want to decode into json. The string was
I want to decode an UT8 encoded string. The input string is øæ-test-2.txt and
http://www.lotterypost.com/js-compress.aspx This is site is very nice for compressing JS but I want to
i have encoded my required data in the json object ,but i want to

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.