c# - sort nested Dictionary -


i sort dictionary value in nested dictionary.

dictionary<int, dictionary<string, string>> data = new dictionary<int, dictionary<string, string>>();  dictionary<string, string> onerow = new dictionary<string,string>(); onerow.add("id", "1"); onerow.add("name", "john"); onerow.add("surname", "petrucci"); onerow.add("data", "2014-01-01"); onerow.add("active", "1"); this.data[1] = onerow;  onerow = new dictionary<string, string>(); onerow.add("id", "2"); onerow.add("name", "joe"); onerow.add("surname", "satriani"); onerow.add("data", "2014-02-02"); onerow.add("active", "1"); this.data[2] = onerow;  onerow = new dictionary<string, string>(); onerow.add("id", "3"); onerow.add("name", "steve"); onerow.add("surname", "vai"); onerow.add("data", "2014-03-03"); onerow.add("active", "0"); this.data[3] = onerow; 

how can sort this.data 'name' or example 'surname' desc ?

i searching have not found solution.

here shortest way:

data = data.orderbydescending(x => x.value["name"])            .todictionary(x => x.key, x => x.value); 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -