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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:34:03+00:00 2026-06-14T15:34:03+00:00

I am using Python 2.5. I have a dictionary with a list of lists

  • 0

I am using Python 2.5. I have a dictionary with a list of lists as values

{'a': [['6', 3]], 'b': [['5', 1], ['6', 5]], 'c': [['446', 2],['6', 11],['67', 86]] }

I want to sort it by the 2nd element of the first list item, so, the above would be sorted like this:

'b': [['5', 1], ['6', 5]], 
'c': [['446', 2],['6', 11],['67', 86]]
'a': [['6', 3]]

Any suggestions?

Thanks
Scott

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

    A dictionary itself is unordered, so you can’t sort it per se. If you want to create a sorted list of the key-value pairs, you can do that:

    sorted(myDict.iteritems(), key=lambda x: x[1][0][1])
    

    iteritems returns an iterable of (key, value) pairs, so x[1][0][1] there means “take the second element of this pair (which is the value), and take the first element of that (which is the first list in the list of lists) and take the second element in that — in order words, the second element in the first list, which is what you want.

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

Sidebar

Related Questions

Using python 2.6: I have a dictionary where each key contains a list of
I have a process that pickles a dictionary using Python 3.2. I then need
I have a python logger set up, using python's logging module. I want to
I have a coordinated storage list in python A[row,col,value] for storing non-zeros values. How
I just started using/learning Python and have some questions. I have a text file
I am new to selenium and I am using python but I have a
Does Python have a built-in, simple way of encoding/decoding strings using a password? Something
I have a working application using python and zeromq and I would like to
I'm using Python, and I have a file which has city names and information
I am using Python 2.7 . I have an alphanumeric string, on which I

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.