【发布时间】:2016-07-29 13:03:18
【问题描述】:
我刚刚写了一些代码,将数据添加到这个字典中:
Dictionary<string, Dictionary<string, double>> studentsExamsMarks =
new Dictionary<string, Dictionary<string, double>>();
studentsExamsMarks.Add("Peter", new Dictionary<string, double>());
studentsExamsMarks["Peter"].Add("History", 5.15);
studentsExamsMarks["Peter"].Add("Biology", 4.20);
studentsExamsMarks["Peter"].Add("Physics", 4.65);
studentsExamsMarks.Add("John", new Dictionary<string, double>());
studentsExamsMarks["John"].Add("History", 6.00);
studentsExamsMarks["John"].Add("Biology", 3.75);
studentsExamsMarks["John"].Add("Physics", 4.15);
studentsExamsMarks.Add("Michael", new Dictionary<string, double>());
studentsExamsMarks["Michael"].Add("History", 3.00);
studentsExamsMarks["Michael"].Add("Biology", 3.95);
studentsExamsMarks["Michael"].Add("Physics", 4.95);
我应该如何首先按学生姓名(升序)排序和打印,而不是按内部字典中的双精度值或主题名称排序和打印?如果您向我展示两个版本,我将非常感激。谢谢!
【问题讨论】:
-
请阅读How to Ask 并分享您的研究。分组和排序在 MSDN、网络和本网站上有非常广泛的记录。
标签: c# linq sorting dictionary