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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:40:00+00:00 2026-05-18T07:40:00+00:00

I have a dictionary like the following. Key value pairs or username:name d =

  • 0

I have a dictionary like the following. Key value pairs or username:name

d = {"user2":"Tom Cruise", "user1": "Tom Cruise"}

My problem is that i need to sort these by the Name, but if multiple users contain the same name like above, i then need to sort those by their username. I looked up the sorted function but i dont really understand the cmp parameter and the lambda. If someone could explain those and help me with this that would be great! Thanks 🙂

  • 1 1 Answer
  • 1 View
  • 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-18T07:40:01+00:00Added an answer on May 18, 2026 at 7:40 am

    cmp is obsolescent. lambda just makes a function.

    sorted(d.iteritems(), key=operator.itemgetter(1, 0))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does VBA have dictionary structure? Like key<>value array?
I want to sort the Dictionary value following is my dictionary response that have
I have a class like the following: public class DropDownControl<T, Key, Value> : BaseControl
I have a dictionary that goes like this: typedef struct dictNode { int key;
I have passed to template dictionary parameters like parameters={ 'value':'some_value', 'style':{} } and inside
Say that i have a generic dictionary with data like this (I hope the
I have a specialized string dictionary of (string, string) (_RulesAndTheirDescriptions) that contains the name
I have a dictionary like this: user_dict = { user1: [(video1, 10), (video2, 20),
I have a list of data that looks like the following: // timestep,x_position,y_position 0,4,7
I want to save the following value in C# 10.1.2.1 <name of branch like

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.