惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
J
Java Code Geeks
雷峰网
雷峰网
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
S
Securelist
The Hacker News
The Hacker News
The Register - Security
The Register - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
AI
AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
博客园 - 司徒正美
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
U
Unit 42
V
V2EX
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
美团技术团队
小众软件
小众软件
F
Fortinet All Blogs

博客园 - 朱小能

linq to sql中的自动缓存(对象跟踪) javascript 调用webservice 的几种方法 修改域名映射IP地址 SQL 语句,类型转换 hyper-v 网络连接 VS2010 定位文件在solution中的位置 oracle连接字符串配置 spool的简单使用 open数据库Timeout expired 错误 文件的还原与备份 - 朱小能 - 博客园 ASCII码,对应e.KeyChar C# 调用计算器,日历 - 朱小能 - 博客园 Excel 如何由一个文本算术公式得到一个结果 Word、Excel中输入当前日期及时间的快捷键 c# ToString 格式化数字 - 朱小能 GridView绑定 获取access中表的相关信息 Filelog - 朱小能 - 博客园 List<T> 排序 - 朱小能 - 博客园
C#对Dictionary的按Value排序
朱小能 · 2013-10-06 · via 博客园 - 朱小能

使用List对其进行排序

using System; using System.Collections.Generic; using System.Text;

namespace ConsoleApplication4 {     class Program     {         static void Main(string[] args)         {

            Dictionary<string, string> dic = new Dictionary<string, string>();

            dic.Add("Arraymin", "c:\\demo\\min.xsl");

            dic.Add("Arraymax", "c:\\demo\\max.xsl");

            dic.Add("Arrayr", "c:\\demo\\r.xsl");

            List<KeyValuePair<string, string>> myList = new List<KeyValuePair<string, string>>(dic);

            myList.Sort(delegate(KeyValuePair<string, string> s1, KeyValuePair<string, string> s2)                 {

                    return s1.Value.CompareTo(s2.Value);

                });

            dic.Clear();

            foreach (KeyValuePair<string, string> pair in myList)             {

                dic.Add(pair.Key, pair.Value);

            }

            foreach (string key in dic.Keys)             {

                Console.WriteLine(dic[key]);

            }

            Console.ReadKey();         }            } }

C#3.0 Lambda表达式 (VS2008)的实现方法:

            Dictionary<string, string> dic = new Dictionary<string, string>();

           dic.Add("Arraymin", "c:\\demo\\min.xsl");

            dic.Add("Arraymax", "c:\\demo\\max.xsl");

            dic.Add("Arrayr", "c:\\demo\\r.xsl");

            var list = dic.OrderBy(s => s.Value);

            foreach (var s in list)

            {

                Console.WriteLine(dic[key]);            }

C#3.0 Linq (VS2008)的实现方法:

            Dictionary<string, string> dic = new Dictionary<string, string>();

            dic.Add("Arraymin", "c:\\demo\\min.xsl");

            dic.Add("Arraymax", "c:\\demo\\max.xsl");

            dic.Add("Arrayr", "c:\\demo\\r.xsl");

            var dicSort = from d in dic

                          orderby d.Value

                          ascending

                          select d;

            foreach (string key in dic.Keys)

            {

              Console.WriteLine(dic[key]);

            }

参考:http://blog.csdn.net/meifage2/article/details/6623272