본문 바로가기

★Dev★/Linq

[Linq] QueryOperator - OrderBy

// OrderBy(), OrderByDescending() : 정렬 출력

List<string> cameraList = new List<string> { "Likon""Canon""Sony" };

 

Response.Write("기본 ======== <br />");  foreach (var camera in cameraList) {     Response.Write(camera + "<br />");  } // OrderBy() : Ascending 정렬 -> 오름차순 정렬 Response.Write("오름차순 정렬 ======== <br />");  foreach (var camera in cameraList.OrderBy(n => n)) {     Response.Write(camera + "<br />");                 } Response.Write("내림차순 정렬 ======== <br />"); // OrderByDescending() : 역순 -> 내림차순 정렬 foreach (var camera in cameraList.OrderByDescending(a => a)) {     Response.Write(camera + "<br />"); }

 

 

 

'★Dev★ > Linq' 카테고리의 다른 글

[Linq] QueryOperator - Where  (0) 2014.12.06
[Linq] QueryOperator - Single  (0) 2014.11.26
[Linq] QueryOperator - Select / SelectMany  (0) 2014.11.25
[Linq] xml - Load  (0) 2014.11.25