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 6604683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:11:23+00:00 2026-05-25T19:11:23+00:00

I have a python dictionary that I want to sort according to name: location_map_india

  • 0

I have a python dictionary that I want to sort according to name:

location_map_india = {
  101: {'name': 'Andaman & Nicobar Islands', 'lat': 11.96, 'long': 92.69, 'radius': 294200},  
  108: {'name': 'Andhra Pradesh', 'lat': 17.04, 'long': 80.09, 'radius': 294200},
...
}

It doesn’t come out the way I expect it. I tried:

location_map_india = sorted(location_map_india.iteritems(), key=lambda x: x.name)

The above didn’t work. What should I do?

Update

The following was allowed and behaved as expected. Thanks for all the help.
Code:

location_map_india = sorted(location_map_india.iteritems(), key=lambda x: x[1]["name"])

Template:

{% for key,value in location_map_india %}<option value="{{key}}" >{{value.name}}</option>{% endfor %}
  • 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-05-25T19:11:23+00:00Added an answer on May 25, 2026 at 7:11 pm

    You are close. Try:

    location_map_india = sorted(location_map_india.iteritems(), key=lambda x: x[1]["name"])
    

    but the result would be a list not a dict. dict is orderless.

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

Sidebar

Related Questions

I have data in a python dictionary that I'd like to store in a
I have a python function that randomize a dictionary representing a position specific scoring
I have a python module that makes use of a huge dictionary global variable,
So I have this code in python that writes some values to a Dictionary
I have an object with a dictionary that I want to access via __getitem__
I have a dictionary, lets call it myDict , in Python that contains a
I have a python dictionary object that contains a boolean for every key, e.g.:
I have a dictionary that I want to write to a csv file, but
Let's say that I have a Python dictionary, but the values are a tuple:
I want to merge two CSV files that I have read into python using

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.