2014. 3. 10. 19:18
Descending : 내림차순 (큰수 -> 작은수)
int IComparer<int>.Compare(int a, int b) //implement Compare
{
if (a > b)
return -1; //normally greater than = 1
if (a < b)
return 1; // normally smaller than = -1
else
return 0; // equal
}
Ascending : 오름차순 (작은수 -> 큰수)
int IComparer<int>.Compare(int a, int b) //implement Compare
{
if (a < b)
return -1; //normally greater than = 1
if (a > b)
return 1; // normally smaller than = -1
else
return 0; // equal
}
결국. 리턴값이 1이면 순서를 바꾼다.
'Programming > C#' 카테고리의 다른 글
[delegate/event] 이벤트 핸들러 내에서 해당 이벤트의 제거. (0) | 2015.12.01 |
---|