Tags
- Intellij
- postman automations
- 프런트엔드
- postman csv
- 다빈치 리졸브
- postman session
- 좋은 개발자
- postman collection
- LSL_Script
- Front-end developer
- postman pre-request
- Android/iOS Developer
- Interaction developer
- oracle
- 우수한 프런트 개발자
- emplace_back
- Unity
- MFC
- web developer
- Java
- postman excel
- Android
- C++
- postman
- postman tests
- c#
- UI/UX Engineer
- postman collection variables
- postman html parse
- solidity
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Archives
- Today
- Total
david's daily developer note
C#, Collection Type Sorting [ Query Keyword , "orderby" , Sorting] 본문
[Develop] Language/C#
C#, Collection Type Sorting [ Query Keyword , "orderby" , Sorting]
mouse-david 2010. 10. 1. 18:13728x90
감동이다. Dictionary Type에서 DBMS에 대한 비슷한 형식의 질의를 통해서, 결과를 받을 수 있다.
다음의 Dictionary 예(d)가 있을 때, Sorting을 위한 순서는 대략 이렇다.
1. Dictionary d의 키 값의 집합 k를 인덱스로하여, 접근.
2. key값으로 접근된 d의 값을 내림차순으로 정렬,
3.value에 의해 정렬된 key을 변수 items에 쏙~
Example program that sorts Dictionary (C#)
// Example dictionary
var d = new Dictionary<string, int>();
d.Add("cat", 1);
d.Add("dog", 0);
d.Add("mouse", 5);
d.Add("eel", 3);
d.Add("programmer", 2);
// 2.
// Order by values.
// Use LINQ to specify sorting by value.
var items = from k in d.Keys
orderby d[k] ascending // descending
select k;
// 3.
// Display results.
foreach (string k in items)
{
Console.WriteLine("{0}: {1}", k, d[k]);
}
// Pause.
Console.Read();
OutPut
dog: 0
cat: 1
programmer: 2
eel: 3
mouse: 5
728x90
'[Develop] Language > C#' 카테고리의 다른 글
C#, 상속 관계가 존재하는 Class들에 대한 is연산중 범할 수 있는 논리 오류.. (0) | 2010.10.27 |
---|---|
.NET 텍스트 파일 한글 읽어오기. (0) | 2010.10.27 |
.NET 설치 및 배포파일 만들기. (0) | 2010.09.29 |
C#, Command창 명령어 실행하기. (0) | 2010.08.27 |
C#, 코드 수행 시간 측정. (0) | 2010.06.29 |