c# dictionary,list排序
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排序的更多相关文章
- C#对 Dictionary进行排序 转
C# .net 3.5 以上的版本引入 Linq 后,字典Dictionary排序变得十分简单,用一句类似 sql 数据库查询语句即可搞定:不过,.net 2.0 排序要稍微麻烦一点,为便于使用,将总 ...
- Linq在Array,List,Dictionary中的应用
Linq在Array,List,Dictionary中的应用 今天在实际工作中需要对array,list,dictionary进行排序,试一试linq,发现非常好用,代码如下: using Syste ...
- 转:python dict按照value 排序
我们知道Python的内置dictionary数据类型是无序的,通过key来获取对应的value.可是有时我们需要对dictionary中 的item进行排序输出,可能根据key,也可能根据value ...
- (转)Python 字典排序
我们知道Python的内置dictionary数据类型是无序的,通过key来获取对应的value.可是有时我们需要对dictionary中 的item进行排序输出,可能根据key,也可能根据value ...
- C# 键值对排序
static void Main(string[] args) { SortedList sl = new SortedList(); sl.Add("001", "Za ...
- OrderBy排序和IComparer的使用
https://www.cnblogs.com/May-day/p/7490334.html 一,OrderBy排序在MDSN中有两种使用方法,如下 1>第一种方法的使用,就是根据某个字段排序, ...
- python dict sorted 排序
https://www.cnblogs.com/linyawen/archive/2012/03/15/2398292.html 我们知道Python的内置dictionary数据类型是无序的,通过k ...
- python的dict如何排序
Python的内置dictionary数据类型是无序的,通过key来获取对应的value.可是有时我们需要对dictionary中 的item进行排序输出,可能根据key,也可能根据value来排 # ...
- 2.排序检索数据 ---SQL
order by 一.排序数据 SELECT prod_name FROM Products ORDER BY prod_name; ORDER BY子句的位置 在指定一条ORDER BY子句时,应该 ...
随机推荐
- AndroidUI-适应不同屏幕和分辨率的做法
- Tomcat设计模式分析(转) 2
Tomcat 系统架构与设计模式,第 2 部分: 设计模式分析 这个分为两个部分的系列文章研究了 Apache Tomcat 服务器的系统架构以及其运用的很多经典设计模式.第 1 部分 分析了 Tom ...
- 自编jQuery插件实现模拟alert和confirm
现在绝大多数网站都不用自带的alert和confirm了,因为界面太生硬了.因此这个插件就这样产生了自己定制一个的想法...... 啥也不说,先上图,有图有真相 :) 现在绝大多数网站都不用自带的al ...
- 关于一种fastjson的死循环情况记录
最近在一次项目中,使用fastjson做接口转换中,碰到了一个Stack Overflow.发现在getxxx方法内如果再次嵌套使用fastjson作json转换,就会无限循环. 错误实例: clas ...
- sleep(0)作用
假设现在是 2008-4-7 12:00:00.000,如果我调用一下 Thread.Sleep(1000) ,在 2008-4-7 12:00:01.000 的时候,这个线程会 不会被唤醒?某人的代 ...
- mysql 自增id
在开发的时候遇到了 自增id变成2147483647 莫名其妙 然后发现是自己没把自增id改为 无符号的原因 把无符号勾上就ok了
- eclipse -- propedit 安装.
SSH 项目中.用到国际化文件,Message.properties 但里面的文本都是 unicode 格式的,用起来不谁.而且也不想通过其它工具转码来使用. 可以通过安装 eclipse 的 pro ...
- 2018年长沙理工大学第十三届程序设计竞赛 H数学考试
链接:https://www.nowcoder.com/acm/contest/96/H来源:牛客网 数学考试 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6 ...
- 虚拟化系列-VMware vSphere 5.1 简介与安装
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://mabofeng.blog.51cto.com/2661587/1017680 一 ...
- find查找、split分隔、replace替换
#!/usr/bin/env python r = "asada" ret = r.find("d") print(ret)#返回所在位置的索引 ret =r. ...