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子句时,应该 ...
随机推荐
- 学习动态性能表(12)--v$db_object_cache
学习动态性能表 第12篇--V$DB_OBJECT_CACHE 2007.6.4 本视图提供对象在library cache(shared pool)中对象统计,提供比v$librarycache更 ...
- Oracle中查询前10条记录
在Oracle怎样查询表中的top10条记录呢? select * from test where rownum <=10 ----说明:rownum只能用于<或<=运算,如 ...
- php 数组NULL元素的批量处理
$a = array('a'=>1, 'b'=>0, 'c'=>NULL); foreach($a as $k=>$v) { // if( is_null($a[$k])) ...
- poj 3463 Sightseeing——次短路计数
题目:http://poj.org/problem?id=3463 当然要给一个点记最短路和次短路的长度和方案. 但往优先队列里放的结构体和vis竟然也要区分0/1,就像把一个点拆成两个点了一样. 不 ...
- [转载]python的range()函数用法
使用python的人都知道range()函数很方便,今天再用到他的时候发现了很多以前看到过但是忘记的细节.这里记录一下range(),复习下list的slide,最后分析一个好玩儿的冒泡程序. 这里记 ...
- java代码equals方法
package com.bc; public class Test_6 { // 我们知道java中的每个类都继承自Object类,equals是Object方法之一 String name; int ...
- git学习5 ecipse集成git(转载)
原文地址:http://blog.csdn.net/hhhccckkk/article/details/10458159 有的eclipse已经自带了GIt了,就不用安装了 1: 进行安装Git,和安 ...
- 侯捷STL学习(12)--STL相关内容hash+tuple
layout: post title: 侯捷STL学习(12) date: 2017-08-01 tag: 侯捷STL --- 第四讲 STL相关的内容 Hash Function 将hash函数封装 ...
- Rails通过页面Debug
<%= debug(headers) %>--在视图中显示伴随请求的头部信息 <%= debug(params) %>--在视图中显示请求中的参数 <%= debug(a ...
- PhoneGap应用图标icon和启动页面SplashScreen
app/config.xml <icon gap:platform="android" gap:qualifier="ldpi" src="re ...