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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:57:48+00:00 2026-06-10T09:57:48+00:00

I have a dictionary with ints for keys, and strings for values. I need

  • 0

I have a dictionary with ints for keys, and strings for values. I need to to sort by the strings, so that when I go dict.values() I get the sorted list.

The strings are values like this: 45_12_something_23

I need to sort numbers as numbers and strings as strings. A given row is guaranteed to be either a string or a number (not a mixture).

Whats a good way to do this in python? Performance isnt an issue.

  • 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-10T09:57:50+00:00Added an answer on June 10, 2026 at 9:57 am

    Convert your dictionary to a list of (key,value) pairs. Sort them however you’d like. (Or is that your question – how to do that?) Then insert the sorted (key,value) pairs into a collections.OrderedDict, which will remember the insertion order and use the same order when iterating.

    Note that you can’t modify the dict you already have, this will make a new dict with the properties you want.

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

Sidebar

Related Questions

I have a dictionary with keys that are ints. I would like to get
Suppose I have Dictionary like this: Dictionary<string, string> values = new Dictionary<string, string>() {
I have a List of Dictionaries that have keys of type string and values
I have a dictionary, user_dict, and create a list for each user value, this
I have a dictionary that has keys associated with lists. mydict = {'fruits': ['banana',
Assume we have dictionary that translates strings into numbers. How to reverse it into
The problem: I have Dictionary<String, String> that I need an alias to, but I
Basically, I have a dictionary where all the keys are ints where the highest
I have: Dictionary<int, List<int>> dict = new ... var a = SomeEntity.Where(f => dict[f.key].Contains(f.someValue))
I have dictionary that is populated and I have no control of. I need

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.