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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:50:19+00:00 2026-05-27T17:50:19+00:00

I have this list : List<Dictionary<int, string>> list = new List<Dictionary<int, string>>(); and I’d

  • 0

I have this list :

List<Dictionary<int, string>> list = new List<Dictionary<int, string>>();

and I’d like to order it (ascending) based on Dictionary int value. How can I do it?

Example :

Dictionary<int, string> Min1 = new Dictionary<int, string>();
Dictionary<int, string> Min2 = new Dictionary<int, string>();
Dictionary<int, string> Min3 = new Dictionary<int, string>();
Dictionary<int, string> Min4 = new Dictionary<int, string>();
Dictionary<int, string> Min5 = new Dictionary<int, string>();

Min1.Add(3, "name");
Min2.Add(1, "hello");
Min3.Add(5, "marco");
Min4.Add(4, "is");
Min5.Add(2, "my");

List<Dictionary<int, string>> list = new List<Dictionary<int, string>>();
list.Add(Min1);
list.Add(Min2);
list.Add(Min3);
list.Add(Min4);
list.Add(Min5);

// NOW I NEED TO ORDER list BASED ON DICTIONARY INT VALUE
// SO THE ORDER ON THE LIST SHOULD BE Min2, Min5, Min1, Min4, Min3

I’d like to sort the list, so when I cycle it and I get to the string I print “hello my name is marco”

  • 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-27T17:50:20+00:00Added an answer on May 27, 2026 at 5:50 pm

    if you want to flatten data and sort them you can try this:

    list.SelectMany(x=>x).OrderBy(x=>x.Key)
    

    but if you don’t like flatten data and just sort dictionaries you can do:

    list.Select(x=>x.OrderBy(y=>y.Key));
    

    Edit: As I understand you just need use one dictionary, so you can do this:

    Dictionary<int,string> dic = new Dictionary<int,string>();
    var result = dic.OrderBy(x=>x.Key).ToLookup(x=>x);
    

    If you want use List instead of dictionary (in your case seems is not good) you can do this;

     List<KeyValuePair<int,string>> lst1 = new List<KeyValuePair<int,string>>();
     var result = lst1.OrderBy(x=>x.Key).ToLookup(x=>x);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a collection like this List<int> {1,15,17,8,3}; how to get a flat string
I have the following List : List<Dictionary<int, Dictionary<string, string>>> lngList lngList.Add(new Dictionary<int,Dictionary<string,string>>().Add(1,new Dictionary<string,string>().Add(Item1Key,Item1Value))); lngList.Add(new
I have this structure: static Dictionary<int, Dictionary<int, string>> tasks = new Dictionary<int, Dictionary<int, string>>();
I have this code: List<string> lineList = new List<string>(); in j = 0; Dictionary<string,
I have a List of String like List<String> MyList=new List<String>{A,B}; and a Dictionary<String, Dictionary<String,String>>
i have this code: var list = new List<int>(); for(int i=0;i<10;i++) list.Add(i); for(int i=0;i<10;i++)
I have this controller method: public JsonResult List(int number) { var list = new
I have a list like List<string> TempList = new List<string> { [66,X,X], [67,X,2], [x,x,x]
I have this code, void Generate(List<string> comb, string prefix, string remaining) { int currentDigit
When I have a Dictionary<string, int> actual and then create a completely new Dictionary<string,

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.