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이면 순서를 바꾼다.

Posted by 바하무트