Dictionary Key排序

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

Dictionary<string, string> dctNew = dct.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);

list Key排序

Public class student{

    public int grade
{
set;
get;
} public int age
{
set;
get;
} public string name
{
set;
get;
}
} List<student> students = new List<student>();
students.OrderBy(x=>x.grade).ThenBy(x=>x.age);

  

c# dictionary,list排序的更多相关文章

  1. C#对 Dictionary进行排序 转

    C# .net 3.5 以上的版本引入 Linq 后,字典Dictionary排序变得十分简单,用一句类似 sql 数据库查询语句即可搞定:不过,.net 2.0 排序要稍微麻烦一点,为便于使用,将总 ...

  2. Linq在Array,List,Dictionary中的应用

    Linq在Array,List,Dictionary中的应用 今天在实际工作中需要对array,list,dictionary进行排序,试一试linq,发现非常好用,代码如下: using Syste ...

  3. 转:python dict按照value 排序

    我们知道Python的内置dictionary数据类型是无序的,通过key来获取对应的value.可是有时我们需要对dictionary中 的item进行排序输出,可能根据key,也可能根据value ...

  4. (转)Python 字典排序

    我们知道Python的内置dictionary数据类型是无序的,通过key来获取对应的value.可是有时我们需要对dictionary中 的item进行排序输出,可能根据key,也可能根据value ...

  5. C# 键值对排序

    static void Main(string[] args) { SortedList sl = new SortedList(); sl.Add("001", "Za ...

  6. OrderBy排序和IComparer的使用

    https://www.cnblogs.com/May-day/p/7490334.html 一,OrderBy排序在MDSN中有两种使用方法,如下 1>第一种方法的使用,就是根据某个字段排序, ...

  7. python dict sorted 排序

    https://www.cnblogs.com/linyawen/archive/2012/03/15/2398292.html 我们知道Python的内置dictionary数据类型是无序的,通过k ...

  8. python的dict如何排序

    Python的内置dictionary数据类型是无序的,通过key来获取对应的value.可是有时我们需要对dictionary中 的item进行排序输出,可能根据key,也可能根据value来排 # ...

  9. 2.排序检索数据 ---SQL

    order by 一.排序数据 SELECT prod_name FROM Products ORDER BY prod_name; ORDER BY子句的位置 在指定一条ORDER BY子句时,应该 ...

随机推荐

  1. 在Azure上通过Powershell创建多Interface的Cisco CSR路由器

    前面通过Json的Template在Azure上创建了Cisco的CSR路由器.但那个Json的template只支持1块网卡.如果需要多网卡的Cisco CSR路由器,可以改上篇文章中提到的Json ...

  2. GXT4.0 BorderLayoutContainer布局

    T字型布局. @Override public void onModuleLoad() { BorderLayoutContainer con = new BorderLayoutContainer( ...

  3. SQL简单嵌套查询与非嵌套查询的比较(MSSQL2005)

    某天的工作是修复某个项目的bug,接着就发现,其sql极其混乱,有非常多的left join和in操作,还有嵌套查询(只有一个表的嵌套查询).不知道看到过哪里的资料说,嵌套查询速度慢,于是我把全部嵌套 ...

  4. spring中JavaConfig相关的注解

    在spring3.0中增加配置spring beans的新方式JavaConfig,可以替换spring的applicataion.xml配置.也即@Configuration对等<beans/ ...

  5. nignx 重启

    sudo /opt/nginx/sbin/nginx -s stop sudo /opt/nginx/sbin/nginx

  6. [Apache]架设Apache服务器

    我自己使用的是Ubuntu的操作系统, 所以我主要是记录的在ubuntu的Apache的安装和简单的配置. Apache服务器的架设: 一.命令行安装 使用下面的指令下载apache2 sudo ap ...

  7. hadoop 常用端口 及模块介绍

    50070                 namenode http port 50075                 datanode   http  port 50090          ...

  8. Android 使用SWIG生成Jni代码<转>

    http://blog.csdn.net/u010780612/article/details/51066819 感觉也就那样把,我没有编译成功,实用性暂时没看到多大优点...

  9. [Python Study Notes]pandas.DataFrame.plot()函数绘图

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...

  10. 修改 linux 时区时间和 php 时区

    问题:客户美国服务器时间不对第一步,先修改硬件时区. vim /etc/sysconfig/clock将 ZONE="America/New_York" 注释,加多一行 ZONE= ...